Skip to content

Commit

Permalink
Merge pull request #87 from georchestra/fix-preauth-user-authenticate…
Browse files Browse the repository at this point in the history
…d-set-to-false

preauth - making sure the authenticated flag on the token is set to true
  • Loading branch information
pmauduit committed Dec 6, 2023
2 parents 95ee6ec + cdf03f4 commit 009a9fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Mono<Authentication> convert(ServerWebExchange exchange) {
throw new IllegalStateException("Pre-authenticated user headers not provided");
}
PreAuthenticatedAuthenticationToken authentication = new PreAuthenticatedAuthenticationToken(username,
credentials);
credentials, List.of());
return Mono.just(authentication);
}
return Mono.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,16 @@ private WebTestClient.RequestHeadersUriSpec<?> prepareWebTestClientHeaders(
.isNotEmpty();
}

public @Test void test_preauthenticatedHeadersAccess_isAuthenticated() {
assertNotNull(context.getBean(PreauthGatewaySecurityCustomizer.class));
assertNotNull(context.getBean(PreauthenticatedUserMapperExtension.class));

ResponseSpec exchange = prepareWebTestClientHeaders(testClient.get(), ADMIN_HEADERS).uri("/whoami").exchange();
BodyContentSpec body = exchange.expectStatus().is2xxSuccessful().expectBody();
body.jsonPath("$.['GeorchestraUser']").isNotEmpty();
body.jsonPath(
"$.['org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken'].authenticated")
.isEqualTo(true);
}

}

0 comments on commit 009a9fa

Please sign in to comment.