There could be several reasons why you are not granted permissions when using ".requestMatchers("/").hasAnyAuthority("admin", "staff").anyRequest().authenticated()":
You may not have the "admin" or "staff" authority. Make sure that your user account has been assigned one of these authorities.
Your authentication provider may not be correctly configured to provide the necessary authorities. Check your authentication configuration to make sure that your provider is configured to authenticate users and provide authorities.
Your request may not be mapped correctly to the URL pattern ("/"). Make sure that your request is correctly mapped to this URL pattern.
There may be a problem with your authorization configuration. Check your authorization configuration to make sure that your rules are correctly configured and applied in the correct order.
It is also possible that there are other issues that are causing the problem. If you cannot resolve the issue on your own, you may need to seek additional help from a developer or technical support.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2022-06-30 11:00:00 +0000
Seen: 3 times
Last updated: Apr 07 '21