Skip to content

Commit 40e2f04

Browse files
committed
Merge pull request 'Fix #25725: error when authenticating with token in Authorization header' (#50) from bugfix/25725 into develop
2 parents b89cf72 + e4104e4 commit 40e2f04

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

src/main/java/eu/openanalytics/containerproxy/auth/impl/KeycloakAuthenticationBackend.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,12 @@ public KeycloakAuthenticationToken2(KeycloakAccount account, boolean interactive
239239
@Override
240240
public String getName() {
241241
IDToken token = getAccount().getKeycloakSecurityContext().getIdToken();
242+
if (token == null) {
243+
// when ContainerProxy is accessed directly using the Access Token as Bearer value in the Authorization
244+
// header, no ID Token is present. The AccessTokens provided by Keycloak are in fact ID tokens, so we
245+
// can safely fall back to them.
246+
token = getAccount().getKeycloakSecurityContext().getToken();
247+
}
242248
switch (nameAttribute) {
243249
case IDToken.PREFERRED_USERNAME: return token.getPreferredUsername();
244250
case IDToken.NICKNAME: return token.getNickName();

0 commit comments

Comments
 (0)