Skip to content

Commit 32da46e

Browse files
committed
Fail early if the access token is not returned from GitHub
1 parent cd488f9 commit 32da46e

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
@@ -864,10 +864,15 @@ public Uni<SecurityIdentity> apply(final AuthorizationCodeTokens tokens, final T
864864
if (isIdTokenRequired(configContext)) {
865865
LOG.errorf("ID token is not available in the authorization code grant response");
866866
return Uni.createFrom().failure(new AuthenticationCompletionException());
867-
} else {
867+
} else if (tokens.getAccessToken() != null) {
868868
tokens.setIdToken(generateInternalIdToken(configContext, null, null,
869869
tokens.getAccessTokenExpiresIn()));
870870
internalIdToken = true;
871+
} else {
872+
LOG.errorf(
873+
"Neither ID token nor access tokens are available in the authorization code grant response."
874+
+ " Please check logs for more details, enable debug log level if no details are visible.");
875+
return Uni.createFrom().failure(new AuthenticationCompletionException());
871876
}
872877
} else {
873878
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
@@ -802,6 +802,10 @@ private Uni<UserInfo> getUserInfoUni(Map<String, Object> requestData, TokenAuthe
802802

803803
LOG.debug("Requesting UserInfo");
804804
String contextAccessToken = (String) requestData.get(OidcConstants.ACCESS_TOKEN_VALUE);
805+
if (contextAccessToken == null && isIdToken(request)) {
806+
throw new AuthenticationCompletionException(
807+
"Authorization code flow access token which is required to get UserInfo is missing");
808+
}
805809
final String accessToken = contextAccessToken != null ? contextAccessToken : request.getToken().getToken();
806810

807811
UserInfoCache userInfoCache = tenantResolver.getUserInfoCache();

0 commit comments

Comments
 (0)