Fix Microsoft OpenID configuration cache serialization#1444
Conversation
|
Should we change the cache key? |
There was a problem hiding this comment.
Pull request overview
This PR addresses a login-breaking caching issue in the Microsoft provider by ensuring the OpenID configuration is cached as an associative array (instead of a stdClass), avoiding __PHP_Incomplete_Class on cache deserialization.
Changes:
- Decode OpenID configuration JSON as associative arrays (
json_decode(..., true)). - Update OpenID configuration usages from object property access to array access.
- Tighten
getOpenIdConfiguration()return type toarray.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
atymic
left a comment
There was a problem hiding this comment.
@ubertech-za can you please change the cache key so its different and does not result in errors for existing users :)
Something like this?
|
|
just add v2 after jwks like |
May be safer if you do this :) You know the codebase better. |
|
Either is fine, new cache key will be different :) |
getOpenIdConfiguration() caches json_decode output as stdClass. On deserialization from file/database cache drivers, PHP returns __PHP_Incomplete_Class, breaking subsequent login attempts. Changes: - Return associative arrays from json_decode instead of stdClass - Update all property access to array syntax - Bump cache keys to openid-v2 and jwks-v2 so stale stdClass entries from prior versions are never read - Update property type from mixed to ?array - Update docblock @return from mixed to array<string, mixed>
27827fe to
544385a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Addresses review feedback: json_decode(..., true) can return null on invalid/empty JSON, which would violate the array return type. Extract decodeOpenIdConfiguration() helper that: - Uses JSON_THROW_ON_ERROR to surface malformed responses - Validates required keys (jwks_uri, issuer) are present - Throws InvalidStateException on failure
getOpenIdConfiguration() caches json_decode output as stdClass. On deserialization from file/database cache drivers, PHP returns __PHP_Incomplete_Class, breaking subsequent login attempts.
Fix: return associative arrays instead of stdClass objects, and update all property access to array syntax.