| | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.springblade.auth.filter.TokenFilterHandle; |
| | | import org.springblade.auth.support.BladePasswordEncoderFactories; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; |
| | | import org.springframework.security.config.annotation.web.builders.HttpSecurity; |
| | | import org.springframework.security.config.annotation.web.builders.WebSecurity; |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | | import org.springframework.security.config.http.SessionCreationPolicy; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| | | |
| | | /** |
| | | * Security配置 |
| | | * |
| | | * @author Chill |
| | | */ |
| | | @Configuration(proxyBeanMethods = false) |
| | | @Configuration |
| | | @AllArgsConstructor |
| | | @EnableGlobalMethodSecurity(prePostEnabled = true,securedEnabled = true,jsr250Enabled = true) |
| | | public class SecurityConfiguration extends WebSecurityConfigurerAdapter { |
| | | |
| | | @Bean |
| | |
| | | http.headers().frameOptions().disable(); |
| | | http.httpBasic().and().csrf().disable(); |
| | | http.formLogin().loginPage("/oauth/login").loginProcessingUrl("/oauth/form"); |
| | | |
| | | // http |
| | | // .addFilterBefore(new TokenFilterHandle(), UsernamePasswordAuthenticationFilter.class)//免登录过滤器 |
| | | // .formLogin().permitAll() |
| | | // // 配置Basic登录 |
| | | // //.and().httpBasic() |
| | | // // 配置登出页面 |
| | | // .and().logout().logoutUrl("/logout").logoutSuccessUrl("/") |
| | | // .and().authorizeRequests().antMatchers("/oauth/**", "/login/**", "/logout/**").permitAll() |
| | | // // 其余所有请求全部需要鉴权认证 |
| | | // .anyRequest().authenticated() |
| | | // // 关闭跨域保护; |
| | | // .and().csrf().disable(); |
| | | } |
| | | |
| | | @Override |