-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
in: testAn issue in spring-security-testAn issue in spring-security-testtype: enhancementA general enhancementA general enhancement
Milestone
Description
It would be handy in tests to be able to specify a Jwt authentication in tests:
this.mockMvc.perform(get("/")
.with(jwt()))
.andExcept(status().isOk());Some features we should consider:
- Providing a completely instantiated
Jwt:
Jwt jwt = ...;
this.mockMvc.perform(get("/")
.with(jwt(jwt)))
...- Providing authorities:
Jwt jwt = ...;
this.mockMvc.perform(get("/")
.with(jwt(jwt).authorities("SCOPE_message:read"))
...- Providing claims:
this.mockMvc.perform(get("/")
.with(jwt().claim(SUB, "the-subject")))
...- Providing headers:
this.mockMvc.perform(get("/")
.with(jwt().header("alg", RS256)))
...These would result in the SecurityContext containing an instance of JwtAuthenticationToken.
Also, we should introduce its reactive equivalent.
Metadata
Metadata
Assignees
Labels
in: testAn issue in spring-security-testAn issue in spring-security-testtype: enhancementA general enhancementA general enhancement