0
我試圖通過引入PreInvocationAuthorizationAdvice
來實現我自己的授權機制。這裏是我的代碼:爲什麼我的PreInvocationAuthorizationAdvice.before未被調用?
我的SecurityContext:
我SecurityAdapter:
@Configuration
@EnableWebSecurity
public class SecurityAdapter extends WebSecurityConfigurerAdapter
{
@Override
protected void configure(HttpSecurity http)
throws Exception
{
http
.authorizeRequests()
.anyRequest().permitAll();
http
.csrf()
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
}
}
最後MyPreInvocationAdvice
public class MyPreInvocationAdvice implements PreInvocationAuthorizationAdvice
{
public MyPreInvocationAdvice()
{
}
@Override
public boolean before(Authentication authentication, MethodInvocation methodInvocation, PreInvocationAttribute preInvocationAttribute)
{
return true;
}
}
在這一刻,我授權的所有請求。但問題是,當我提出請求時,根本不會調用before
方法。有人可以告訴我我犯了什麼錯誤嗎?