* 當我們想要使用多個權限表達式的時候,是不能直接級聯調用的,也就是說,我們只能手寫了。
1 @Override 2 protected void configure(HttpSecurity http) throws Exception { 3 http.formLogin() 4 .and() 5 .authorizeRequests() 6 .antMatchers("/oauth/*","/login/*").permitAll() 7 .antMatchers(HttpMethod.GET,"/auth/*").access("hasRole('admin') and hasIpAddress('127.0.0.1')") 8 .anyRequest().authenticated() //任何請求都需要身份認證 9 .and().csrf().disable(); //禁用CSRF 10 }
*或者說我們想要寫一個權限表達式來讓SpringSecurity走我們自己的認證邏輯。