File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed
Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ Yii Framework 2 authclient extension Change Log
66
77- Enh #387 : Use appropriate exception if client does not exist (eluhr)
88- Enh #388 : Added support to configure the OAuth2 access token location in requests and added a generic OAuth2 client (rhertogh)
9+ - Enh #389 : Added ability to configure OpenIdConnect cache duration, default is 1 week (viktorprogger)
910
1011
11122.2.15 December 16, 2023
@@ -276,6 +277,3 @@ Yii Framework 2 authclient extension Change Log
276277-------------------------
277278
278279- Initial release.
279-
280-
281-
Original file line number Diff line number Diff line change @@ -160,6 +160,10 @@ class OpenIdConnect extends OAuth2
160160 * @var JWKSet Key Set
161161 */
162162 private $ _jwkSet ;
163+ /**
164+ * @var int cache duration in seconds, default: 1 week
165+ */
166+ private $ cacheDuration = 604800 ;
163167
164168
165169 /**
@@ -218,13 +222,13 @@ public function getConfigParams()
218222 $ cacheKey = $ this ->configParamsCacheKeyPrefix . $ this ->getId ();
219223 if ($ cache === null || ($ configParams = $ cache ->get ($ cacheKey )) === false ) {
220224 $ configParams = $ this ->discoverConfig ();
225+
226+ if ($ cache !== null ) {
227+ $ cache ->set ($ cacheKey , $ configParams , $ this ->cacheDuration );
228+ }
221229 }
222230
223231 $ this ->_configParams = $ configParams ;
224-
225- if ($ cache !== null ) {
226- $ cache ->set ($ cacheKey , $ configParams );
227- }
228232 }
229233 return $ this ->_configParams ;
230234 }
@@ -444,13 +448,13 @@ protected function getJwkSet()
444448 ->setUrl ($ this ->getConfigParam ('jwks_uri ' ));
445449 $ response = $ this ->sendRequest ($ request );
446450 $ jwkSet = JWKFactory::createFromValues ($ response );
451+
452+ if ($ cache !== null ) {
453+ $ cache ->set ($ cacheKey , $ jwkSet , $ this ->cacheDuration );
454+ }
447455 }
448456
449457 $ this ->_jwkSet = $ jwkSet ;
450-
451- if ($ cache !== null ) {
452- $ cache ->set ($ cacheKey , $ jwkSet );
453- }
454458 }
455459 return $ this ->_jwkSet ;
456460 }
You can’t perform that action at this time.
0 commit comments