| | |
| | | |
| | | /** |
| | | * 监控权限配置 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @EnableWebSecurity |
| | | public class WebSecurityConfigurer |
| | | { |
| | | private final String adminContextPath; |
| | | |
| | | public WebSecurityConfigurer(AdminServerProperties adminServerProperties) |
| | | { |
| | | this.adminContextPath = adminServerProperties.getContextPath(); |
| | | } |
| | | |
| | | @Bean |
| | | public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception |
| | | { |
| | | SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); |
| | | successHandler.setTargetUrlParameter("redirectTo"); |
| | | successHandler.setDefaultTargetUrl(adminContextPath + "/"); |
| | | |
| | | return httpSecurity |
| | | .headers().frameOptions().disable() |
| | | .and().authorizeRequests() |
| | | .antMatchers(adminContextPath + "/assets/**" |
| | | , adminContextPath + "/login" |
| | | , adminContextPath + "/actuator/**" |
| | | , adminContextPath + "/instances/**" |
| | | , adminContextPath + "*/doc.html" |
| | | ).permitAll() |
| | | .anyRequest().authenticated() |
| | | .and() |
| | | .formLogin().loginPage(adminContextPath + "/login") |
| | | .successHandler(successHandler).and() |
| | | .logout().logoutUrl(adminContextPath + "/logout") |
| | | .and() |
| | | .httpBasic().and() |
| | | .csrf() |
| | | .disable() |
| | | .build(); |
| | | } |
| | | public class WebSecurityConfigurer { |
| | | private final String adminContextPath; |
| | | |
| | | public WebSecurityConfigurer(AdminServerProperties adminServerProperties) { |
| | | this.adminContextPath = adminServerProperties.getContextPath(); |
| | | } |
| | | |
| | | @Bean |
| | | public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { |
| | | SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler(); |
| | | successHandler.setTargetUrlParameter("redirectTo"); |
| | | successHandler.setDefaultTargetUrl(adminContextPath + "/"); |
| | | |
| | | return httpSecurity |
| | | .headers().frameOptions().disable() |
| | | .and().authorizeRequests() |
| | | .antMatchers(adminContextPath + "/assets/**" |
| | | , adminContextPath + "/login" |
| | | , adminContextPath + "/actuator/**" |
| | | , adminContextPath + "/instances/**" |
| | | , adminContextPath + "*/doc.html" |
| | | ).permitAll() |
| | | .anyRequest().authenticated() |
| | | .and() |
| | | .formLogin().loginPage(adminContextPath + "/login") |
| | | .successHandler(successHandler).and() |
| | | .logout().logoutUrl(adminContextPath + "/logout") |
| | | .and() |
| | | .httpBasic().and() |
| | | .csrf() |
| | | .disable() |
| | | .build(); |
| | | } |
| | | } |