Skip to content

Commit 8bf9175

Browse files
authored
Merge pull request quarkusio#47750 from sberyozkin/internal_idtoken_fix
Fail early if the access token is not returned from GitHub
2 parents 617e9f9 + 32da46e commit 8bf9175

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/CodeAuthenticationMechanism.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,10 +845,15 @@ public Uni<SecurityIdentity> apply(final AuthorizationCodeTokens tokens, final T
845845
if (isIdTokenRequired(configContext)) {
846846
LOG.errorf("ID token is not available in the authorization code grant response");
847847
return Uni.createFrom().failure(new AuthenticationCompletionException());
848-
} else {
848+
} else if (tokens.getAccessToken() != null) {
849849
tokens.setIdToken(generateInternalIdToken(configContext, null, null,
850850
tokens.getAccessTokenExpiresIn()));
851851
internalIdToken = true;
852+
} else {
853+
LOG.errorf(
854+
"Neither ID token nor access tokens are available in the authorization code grant response."
855+
+ " Please check logs for more details, enable debug log level if no details are visible.");
856+
return Uni.createFrom().failure(new AuthenticationCompletionException());
852857
}
853858
} else {
854859
if (!prepareNonceForVerification(context, configContext.oidcConfig(), stateBean)) {

extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcIdentityProvider.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ private Uni<UserInfo> getUserInfoUni(Map<String, Object> requestData, TokenAuthe
810810

811811
LOG.debug("Requesting UserInfo");
812812
String contextAccessToken = (String) requestData.get(OidcConstants.ACCESS_TOKEN_VALUE);
813+
if (contextAccessToken == null && isIdToken(request)) {
814+
throw new AuthenticationCompletionException(
815+
"Authorization code flow access token which is required to get UserInfo is missing");
816+
}
813817
final String accessToken = contextAccessToken != null ? contextAccessToken : request.getToken().getToken();
814818

815819
UserInfoCache userInfoCache = tenantResolver.getUserInfoCache();

0 commit comments

Comments
 (0)