Skip to content

Couple of questions about usage #20

Answered by ch4mpy
cvetan asked this question in Q&A
Discussion options

You must be logged in to vote

I had missed that, sorry.

In the output you pasted above, you get a 403 (forbidden) and not a 401 (unauthorized) which means that your request actually had authentication context but that spring-security denied access. A frequent cause for that is security being role based (hasRole('DRIVER') as opposed to hasAuthority('DRIVER')) and GrantedAuthoritiesMapper not being exposed as a @Bean.

If your app uses something else than NullAuthoritiesMapper, you must either

  • expose it as a bean so that test security conf can pick it
  • provide @WithMockKeycloakAuth with already transformed authorities (i.e.: @WithMockKeycloakAuth(authorities = { "ROLE_DRIVER" })

Now an important note about Spring securi…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ch4mpy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants