Spring Security ROLE_ANONYMOUS does not work when deny-by-default is activated

前端 未结 1 1146
予麋鹿
予麋鹿 2021-01-29 09:35

I had enabled deny-by-default feature of security. With this I want to provide anonymous access on some controllers. For that I had enabled Anonymous authentication.

If

相关标签:
1条回答
  • 2021-01-29 09:51

    When using @PreAuthorize(value="hasRole('ROLE_ANONYMOUS')") and anyRequest().authenticated(), you have configured your security chain to authenticate all requests, this catches the anonymous request and rejects it, before it gets to the controller.

    Either you can configure using antMatchers("/").permitAll() or antMatchers("/").anonymous() to pass through the security filter chain.

    0 讨论(0)
提交回复
热议问题