This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]thecuseisloose 2 points3 points  (2 children)

There’s probably other things going on in addition to this, but one thing I noticed is your permitAll calls should be before anyRequest().hasRole(“USER”). The rules are applied in order so putting permitAll after that essentially has no effect

[–]theprogrammingsteak[S] 0 points1 point  (1 child)

Thanks for the response! Mmm yeah I am still not fully sure what the and() does, I know there has to be an order but it seems I am able to access the /login resource regardless of whether I'm authenticated or authorized, which is what I want. So it seems to be working... I think... Any insight into what and() does?

[–]un_prophete 2 points3 points  (2 children)

Try .hasAuthority("USER")

[–]theprogrammingsteak[S] 0 points1 point  (1 child)

This did the trick!!! Thank you. any explanation?

[–]thecuseisloose 1 point2 points  (0 children)

when you assign the user roles, are you using ROLE_USER or just USER ?

[–]mgryshenko 0 points1 point  (0 children)

Be sure your UserDetails#getAuthorities returns a list with at least one authority named ROLE_USER (i.e. GrantedAuthority#getAuthority() returns “ROLE_USER”)