[英]How to change HttpSecurity without WebSecurityConfigurerAdapter
[英]How to use anotation instead of HttpSecurity?
我有帶有OAuth2的Spring Boot應用程序。 我想打開一些端點進行匿名訪問。 我可以使用:
http
.authorizeRequests()
.antMatchers("/xyz/**").anonymous()
.and()
.authorizeRequests()
.anyRequest().authenticated();
但是有什么方法可以有選擇地做到這一點,並通過在其中添加一些注釋來僅打開特定的端點? 我嘗試了@PermitAll
但它仍然需要身份驗證。
您可以使用antMatchers(“ / YOUR_ENDOINT / **”)。permitAll();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.