|
22 | 22 | use OCA\UserOIDC\Event\TokenObtainedEvent; |
23 | 23 | use OCA\UserOIDC\Service\DiscoveryService; |
24 | 24 | use OCA\UserOIDC\Service\LdapService; |
| 25 | +use OCA\UserOIDC\Service\OIDCService; |
25 | 26 | use OCA\UserOIDC\Service\ProviderService; |
26 | 27 | use OCA\UserOIDC\Service\ProvisioningService; |
27 | 28 | use OCA\UserOIDC\Service\TokenService; |
@@ -85,6 +86,7 @@ public function __construct( |
85 | 86 | private LoggerInterface $logger, |
86 | 87 | private ICrypto $crypto, |
87 | 88 | private TokenService $tokenService, |
| 89 | + private OidcService $oidcService, |
88 | 90 | ) { |
89 | 91 | parent::__construct($request, $config); |
90 | 92 | } |
@@ -426,6 +428,17 @@ public function code(string $state = '', string $code = '', string $scope = '', |
426 | 428 | $idTokenPayload = JWT::decode($idTokenRaw, $jwks); |
427 | 429 | } |
428 | 430 |
|
| 431 | + // default is false |
| 432 | + if (isset($oidcSystemConfig['enrich_login_id_token_with_userinfo']) && $oidcSystemConfig['enrich_login_id_token_with_userinfo']) { |
| 433 | + $userInfo = $this->oidcService->userInfo($provider, $data['access_token']); |
| 434 | + foreach ($userInfo as $key => $value) { |
| 435 | + // give priority to id token values, only use userinfo ones if missing in id token |
| 436 | + if (!isset($idTokenPayload->{$key})) { |
| 437 | + $idTokenPayload->{$key} = $value; |
| 438 | + } |
| 439 | + } |
| 440 | + } |
| 441 | + |
429 | 442 | $this->logger->debug('Parsed the JWT payload: ' . json_encode($idTokenPayload, JSON_THROW_ON_ERROR)); |
430 | 443 |
|
431 | 444 | if ($idTokenPayload->exp < $this->timeFactory->getTime()) { |
|
0 commit comments