diff --git a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedResourceServerType.java b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedResourceServerType.java index dfbdfe9d83d..b6b72f5802d 100644 --- a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedResourceServerType.java +++ b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedResourceServerType.java @@ -40,7 +40,7 @@ public Mono call() { .map(Mono::just) .orElseGet(Mono::empty); } else if (authentication instanceof OAuth2AuthenticationToken) { - return Mono.just(ResourceServerType.OAUTH2); + return Mono.just(ResourceServerType.TOKEN_X); } return Mono.empty(); }); diff --git a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedUserId.java b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedUserId.java index 761c65b818f..e5b514f1fb3 100644 --- a/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedUserId.java +++ b/libs/reactive-security/src/main/java/no/nav/testnav/libs/reactivesecurity/action/GetAuthenticatedUserId.java @@ -21,7 +21,7 @@ public Mono call() { return getAuthenticatedResourceServerType .call() .flatMap(serverType -> switch (serverType) { - case TOKEN_X, OAUTH2 -> getTokenAttribute("pid"); + case TOKEN_X -> getTokenAttribute("pid"); case AZURE_AD -> getTokenAttribute("oid"); }); } @@ -38,7 +38,7 @@ private Mono getTokenAttribute(String attribute) { jwtAuthenticationToken.getTokenAttributes().get(attribute).toString(); case OAuth2AuthenticationToken oauth2AuthenticationToken -> - oauth2AuthenticationToken.getPrincipal().getAttributes().get(attribute).toString(); + oauth2AuthenticationToken.getPrincipal().getAttribute("pid"); default -> ""; }; diff --git a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/ResourceServerType.java b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/ResourceServerType.java index 645b9354d95..ee579cb3018 100644 --- a/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/ResourceServerType.java +++ b/libs/security-core/src/main/java/no/nav/testnav/libs/securitycore/domain/ResourceServerType.java @@ -2,6 +2,5 @@ public enum ResourceServerType { TOKEN_X, - AZURE_AD, - OAUTH2 + AZURE_AD }