| | |
| | | import cn.gistack.auth.support.BladePasswordEncoderFactories; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.SneakyThrows; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.security.authentication.AuthenticationManager; |
| | | import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; |
| | | 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; |
| | |
| | | @Configuration(proxyBeanMethods = false) |
| | | @AllArgsConstructor |
| | | public class SecurityConfiguration extends WebSecurityConfigurerAdapter { |
| | | |
| | | @Autowired |
| | | private MyAuthenticationProvider myAuthenticationProvider; |
| | | |
| | | /** |
| | | * 认证设置 |
| | | * @param auth 认证manager |
| | | * @throws Exception 异常 |
| | | */ |
| | | @Override |
| | | protected void configure(AuthenticationManagerBuilder auth) throws Exception { |
| | | //设置自定义认证provider |
| | | auth.authenticationProvider(myAuthenticationProvider); |
| | | } |
| | | |
| | | @Bean |
| | | @Override |
| | |
| | | http.headers().frameOptions().disable(); |
| | | http.httpBasic().and().csrf().disable(); |
| | | http.formLogin().loginPage("/oauth/login").loginProcessingUrl("/oauth/form"); |
| | | |
| | | // 添加对 /v2/api-docs 的访问控制 |
| | | http.authorizeRequests() |
| | | .antMatchers("/v2/api-docs").denyAll(); // 拒绝所有对 /v2/api-docs 的访问 |
| | | } |
| | | |
| | | @Override |