| | |
| | | |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.springblade.auth.constant.Oauth2Constants; |
| | | import org.springblade.auth.support.BladePasswordEncoderFactories; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | |
| | | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; |
| | | import org.springframework.security.crypto.password.PasswordEncoder; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * Security配置 |
| | | * |
| | |
| | | @AllArgsConstructor |
| | | @Order(1) |
| | | public class SecurityConfiguration extends WebSecurityConfigurerAdapter { |
| | | |
| | | @Resource |
| | | private Oauth2Constants oauth2Constants; |
| | | |
| | | @Bean |
| | | @Override |
| | |
| | | @SneakyThrows |
| | | protected void configure(HttpSecurity http) { |
| | | http.headers().frameOptions().disable(); |
| | | http.httpBasic().and().csrf().disable(); |
| | | http.formLogin().loginPage("/oauth/login").loginProcessingUrl("/oauth/form"); |
| | | http.csrf().disable(); |
| | | http.formLogin() |
| | | //自定义认证成功跳转 |
| | | .successHandler(new CustomAuthenticationSuccessHandler(oauth2Constants.getAuthorizeUrl())) |
| | | .loginPage(oauth2Constants.getLoginPage()) |
| | | .loginProcessingUrl(oauth2Constants.getLoginProcessingUrl()) |
| | | .failureHandler(new CustomAuthenticationFailureHandler()) |
| | | ; |
| | | // 认证失败自定义登录页跳转 |
| | | http.exceptionHandling() |
| | | .authenticationEntryPoint(new CustomAuthenticationEntryPoint(oauth2Constants.getLoginPage())); |
| | | |
| | | } |
| | | |
| | | @Override |