Skip to content

Commit

Permalink
Add logging for authentication context and cleanup debug logs #deploy…
Browse files Browse the repository at this point in the history
…-idporten-frontend

Added logging for the authentication context in `JwtResolver` to enhance traceability. Removed redundant debug logs of exchange attributes in multiple classes for clarity and to reduce noise in the logs.
  • Loading branch information
krharum committed Dec 17, 2024
1 parent a757313 commit 3ba51fc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ public Altinn3PersonOrganisasjonTilgangConsumer(

public Mono<Boolean> hasAccess(String organisasjonsnummer, ServerWebExchange exchange) {

exchange.getAttributes()
.forEach((key, value) -> log.info("Atributt {}: {}", key, value));

return getAuthenticatedUserId
.call()
.flatMap(userId -> accessService.getAccessToken(serverProperties, exchange)
Expand All @@ -59,12 +56,10 @@ public Mono<Boolean> hasAccess(String organisasjonsnummer, ServerWebExchange exc

public Flux<OrganisasjonDTO> getOrganisasjoner(ServerWebExchange exchange) {

exchange.getAttributes()
.forEach((key, value) -> log.info("Atributt {}: {}", key, value));

return getAuthenticatedUserId
.call()
.flatMapMany(userId -> accessService.getAccessToken(serverProperties, exchange)
.doOnNext(pid -> log.info("userid {}", pid))
.flatMapMany(accessToken -> new PostPersonOrganisasjonTilgangCommand(webClient, userId, accessToken).call()));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ public class BrukerTilgangController {
@GetMapping("/organisasjoner")
public Mono<List<OrganisasjonDTO>> getOrganisasjoner(ServerWebExchange exchange) {

exchange.getAttributes()
.forEach((key, value) -> log.info("Atributt {}: {}", key, value));

return altinn3PersonOrganisasjonTilgangConsumer.getOrganisasjoner(exchange)
.collectList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Mono<JwtAuthenticationToken> getJwtAuthenticationToken() {
return ReactiveSecurityContextHolder
.getContext()
.switchIfEmpty(Mono.error(new JwtResolverException("ReactiveSecurityContext is empty")))
.doOnNext(context -> log.info("context.authentication {}", context.getAuthentication()))
.map(SecurityContext::getAuthentication)
.map(JwtAuthenticationToken.class::cast)
.doOnError(throwable -> log.warn("Klarte ikke hente Jwt Auth Token", throwable))
Expand Down

0 comments on commit 3ba51fc

Please sign in to comment.