Closed
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.