Skip to content

Commit

Permalink
Refactor variable naming for clarity in authentication logic #deploy-…
Browse files Browse the repository at this point in the history
…idporten-frontend

Updated variable names in `GetAuthenticatedUserId` to improve clarity and align with their actual purpose. Adjusted log statements to provide more relevant details about the authentication context.
  • Loading branch information
krharum committed Dec 17, 2024
1 parent 0d2d46f commit ae444be
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,16 @@ private Mono<String> getTokenAttribute(String attribute) {
return ReactiveSecurityContextHolder
.getContext()
.map(SecurityContext::getAuthentication)
.map(context -> getTokenAttribute(context, attribute));
.map(authentication -> getTokenAttribute(authentication, attribute));
}

private String getTokenAttribute(Authentication context, String attribute) {
private String getTokenAttribute(Authentication authentication, String attribute) {

log.info("context.authentication {}", context);
if (context instanceof JwtAuthenticationToken jwtAuthenticationToken) {
log.info("context.authentication {}, {}", authentication.getClass().getCanonicalName(), authentication);
if (authentication instanceof JwtAuthenticationToken jwtAuthenticationToken) {
return jwtAuthenticationToken.getTokenAttributes().get(attribute).toString();

} else if (context instanceof OAuth2AuthenticationToken oauth2AuthenticationToken) {
} else if (authentication instanceof OAuth2AuthenticationToken oauth2AuthenticationToken) {
log.info("oauth2AuthenticationToken {}", oauth2AuthenticationToken.getPrincipal());
return oauth2AuthenticationToken.getPrincipal().getAttributes().get(attribute).toString();

Expand Down

0 comments on commit ae444be

Please sign in to comment.