潘志宝
2024-12-15 df66283fdc91fd5ebdbcafed07f232e5f7d47238
提交 | 用户 | 时间
e7c126 1 //package com.iailab.monitor.config;
H 2 //
3 //import de.codecentric.boot.admin.server.config.AdminServerProperties;
4 //import org.springframework.context.annotation.Configuration;
5 //import org.springframework.security.config.annotation.web.builders.HttpSecurity;
6 //import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
7 //import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
8 //import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
9 //
10 ///**
11 // * @author scott
12 // */
13 //@Configuration
14 //public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
15 //
16 //    private final String adminContextPath;
17 //
18 //    public SecuritySecureConfig(AdminServerProperties adminServerProperties) {
19 //        this.adminContextPath = adminServerProperties.getContextPath();
20 //    }
21 //
22 //
23 //    @Override
24 //    protected void configure(HttpSecurity http) throws Exception {
25 //        // 登录成功处理类
26 //        SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
27 //        successHandler.setTargetUrlParameter("redirectTo");
28 //        successHandler.setDefaultTargetUrl(adminContextPath + "/");
29 //
30 //        http.authorizeRequests()
31 //                //静态文件允许访问
32 //                .antMatchers(adminContextPath + "/assets/**").permitAll()
33 //                //登录页面允许访问
34 //                .antMatchers(adminContextPath + "/login", "/css/**", "/js/**", "/image/*").permitAll()
35 //                //其他所有请求需要登录
36 //                .anyRequest().authenticated()
37 //                .and()
38 //                //登录页面配置,用于替换security默认页面
39 //                .formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
40 //                //登出页面配置,用于替换security默认页面
41 //                .logout().logoutUrl(adminContextPath + "/logout").and()
42 //                .httpBasic().and()
43 //                .csrf()
44 //                .csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
45 //                .ignoringAntMatchers(
46 //                        "/instances",
47 //                        "/actuator/**"
48 //                );
49 //
50 //    }
51 //
52 //}