2121use League \OAuth2 \Server \ResponseTypes \ResponseTypeInterface ;
2222use LogicException ;
2323use Psr \Http \Message \ServerRequestInterface ;
24+ use SimpleSAML \Module \oidc \Codebooks \FlowTypeEnum ;
2425use SimpleSAML \Module \oidc \Entities \Interfaces \AccessTokenEntityInterface ;
2526use SimpleSAML \Module \oidc \Entities \Interfaces \AuthCodeEntityInterface ;
2627use SimpleSAML \Module \oidc \Entities \Interfaces \RefreshTokenEntityInterface ;
@@ -270,8 +271,7 @@ public function completeOidcAuthorizationRequest(
270271 $ authorizationRequest ->getClient (),
271272 $ user ->getIdentifier (),
272273 $ finalRedirectUri ,
273- $ authorizationRequest ->getScopes (),
274- $ authorizationRequest ->getNonce (),
274+ $ authorizationRequest ,
275275 );
276276
277277 $ payload = [
@@ -307,7 +307,6 @@ public function completeOidcAuthorizationRequest(
307307 }
308308
309309 /**
310- * @param \League\OAuth2\Server\Entities\ScopeEntityInterface[] $scopes
311310 * @throws \League\OAuth2\Server\Exception\OAuthServerException
312311 * @throws \League\OAuth2\Server\Exception\UniqueTokenIdentifierConstraintViolationException
313312 */
@@ -316,25 +315,29 @@ protected function issueOidcAuthCode(
316315 OAuth2ClientEntityInterface $ client ,
317316 string $ userIdentifier ,
318317 string $ redirectUri ,
319- array $ scopes = [],
320- ?string $ nonce = null ,
318+ AuthorizationRequest $ authorizationRequest ,
321319 ): AuthCodeEntityInterface {
322320 $ maxGenerationAttempts = self ::MAX_RANDOM_TOKEN_GENERATION_ATTEMPTS ;
323321
324322 if (!is_a ($ this ->authCodeRepository , AuthCodeRepositoryInterface::class)) {
325323 throw OidcServerException::serverError ('Unexpected auth code repository entity type. ' );
326324 }
327325
326+ $ flowType = $ authorizationRequest ->isVciRequest () ?
327+ FlowTypeEnum::VciAuthorizationCode :
328+ FlowTypeEnum::OidcAuthorizationCode;
329+
328330 while ($ maxGenerationAttempts -- > 0 ) {
329331 try {
330332 $ authCode = $ this ->authCodeEntityFactory ->fromData (
331333 $ this ->generateUniqueIdentifier (),
332334 $ client ,
333- $ scopes ,
335+ $ authorizationRequest -> getScopes () ,
334336 (new DateTimeImmutable ())->add ($ authCodeTTL ),
335337 $ userIdentifier ,
336338 $ redirectUri ,
337- $ nonce ,
339+ $ authorizationRequest ->getNonce (),
340+ flowTypeEnum: $ flowType ,
338341 );
339342 $ this ->authCodeRepository ->persistNewAuthCode ($ authCode );
340343
0 commit comments