![](/img/trans.png)
[英]How can I implement Basic Authentication with JWT authentication in Spring Boot?
[英]I put basic authentication in spring boot but how we access some Api without authentication login
根據標題,我在 spring boot 中放置了一些基本的身份驗證,但是我們如何在沒有身份驗證登錄的情況下訪問某些 API
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest()
.authenticated()
.and()
.httpBasic();
}
過濾掉API並允許所有無需身份驗證
例子
.antMatchers(GET, "/home","/health").permitAll()
這將允許所有請求在 2 個端點上的 GET 請求,即使沒有身份驗證
完整樣品
http
.authorizeRequests()
.antMatchers(GET, "/home","/health").permitAll()
.anyRequest()
.authenticated()
.and()
.httpBasic();
注:需要下單
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.