Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ public function login(int $providerId, ?string $redirectUrl = null) {
'claims' => json_encode($claims),
'state' => $state,
'nonce' => $nonce,
'prompt' => $oidcConfig['prompt'] ?? 'consent'
];

if (isset($oidcConfig['prompt']) && is_string($oidcConfig['prompt'])) {
$data['prompt'] = $oidcConfig['prompt'];
}

if ($isPkceEnabled) {
$data['code_challenge'] = $this->toCodeChallenge($code_verifier);
Expand Down
35 changes: 20 additions & 15 deletions lib/Service/TokenService.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,24 +255,29 @@ public function getExchangedToken(string $targetAudience, array $extraScopes = [
}
}
$this->logger->debug('[TokenService] Exchanging the token: ' . $discovery['token_endpoint']);
$tokenEndpointParams = [
'client_id' => $oidcProvider->getClientId(),
'client_secret' => $clientSecret,
'grant_type' => 'urn:ietf:params:oauth:grant-type:token-exchange',
'subject_token' => $loginToken->getAccessToken(),
'subject_token_type' => 'urn:ietf:params:oauth:token-type:access_token',
// can also be
// urn:ietf:params:oauth:token-type:access_token
// or urn:ietf:params:oauth:token-type:id_token
// this one will get us an access token and refresh token within the response
'requested_token_type' => 'urn:ietf:params:oauth:token-type:refresh_token',
'audience' => $targetAudience,
'scope' => $scope,
];
$oidcConfig = $this->config->getSystemValue('user_oidc', []);
if (isset($oidcConfig['prompt']) && is_string($oidcConfig['prompt'])) {
// none, consent, login and internal for oauth2 passport server
$tokenEndpointParams['prompt'] = $oidcConfig['prompt'];
}
// more in https://www.keycloak.org/securing-apps/token-exchange
$body = $this->clientService->post(
$discovery['token_endpoint'],
[
'client_id' => $oidcProvider->getClientId(),
'client_secret' => $clientSecret,
'grant_type' => 'urn:ietf:params:oauth:grant-type:token-exchange',
'subject_token' => $loginToken->getAccessToken(),
'subject_token_type' => 'urn:ietf:params:oauth:token-type:access_token',
// can also be
// urn:ietf:params:oauth:token-type:access_token
// or urn:ietf:params:oauth:token-type:id_token
// this one will get us an access token and refresh token within the response
'requested_token_type' => 'urn:ietf:params:oauth:token-type:refresh_token',
'audience' => $targetAudience,
'scope' => $scope,
'prompt' => $this->config->getSystemValue('user_oidc.prompt', 'consent') // none,consent,login and internal for oauth2 passport server
]
$tokenEndpointParams,
);
$this->logger->debug('[TokenService] Token exchange request params', [
'client_id' => $oidcProvider->getClientId(),
Expand Down
Loading