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
方法。有人可以告诉我我犯了什么错误吗?