2
我試圖添加一個不安全的控制器端點/foo/bar
到我的應用程序,但每當我嘗試調用它時,我得到401 Unauthorized
。HttpSecurity配置 - 允許所有仍然需要基本的身份驗證
這裏是我WebSecurityConfigurerAdapter
:
http
.authorizeRequests()
.antMatchers("/foo/**").permitAll()
.and()
.formLogin()
.loginPage("/login").permitAll()
.and()
.requestMatchers()
.antMatchers("/login", "/oauth/authorize", "/oauth/confirm_access")
.and()
.authorizeRequests()
.anyRequest().authenticated();
會有人爲好心指出我錯過了什麼?
/富/條,應允許GET或POST或兩者兼而有之? – Sanj
@Sanj驗證機制不應該考慮,方法被RequestMapping過濾掉 – Benedictus