package cn.codesheep.sba_server_2_0;
import de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration;
import de.codecentric.boot.admin.server.config.AdminServerProperties;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
@SpringBootApplication
@EnableAdminServer
public class SbaServer20Application {
public static void main(String[] args) {
SpringApplication.run(SbaServer20Application.class, args);
}
@Profile("insecure")
@Configuration
public static class SecurityPermitAllConfig extends WebSecurityConfigurerAdapter{
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll().and().csrf().disable();
}
}
@Profile("secure")
@Configuration
public static class SecuritySecureConfig extends WebSecurityConfigurerAdapter{
private String adminContextPath;
public SecuritySecureConfig( AdminServerProperties adminServerProperties ) {
this.adminContextPath = adminServerProperties.getContextPath();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
http.authorizeRequests().antMatchers(adminContextPath+"/assets/**").permitAll()
.antMatchers(adminContextPath+"/login").permitAll().anyRequest().authenticated().and().formLogin()
.loginPage(adminContextPath+"/login").successHandler(successHandler).and().logout()
.logoutUrl(adminContextPath+"/logout").and().httpBasic().and().csrf().disable();
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
spring_boot_admin2.0_demo.7z
共20个文件
ds_store:5个
properties:5个
java:4个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 130 浏览量
2023-07-13
16:00:52
上传
评论
收藏 43KB 7Z 举报
温馨提示
spring_boot_admin2.0_demo.7z
资源推荐
资源详情
资源评论
收起资源包目录
spring_boot_admin2.0_demo.7z (20个子文件)
spring_boot_admin2.0_demo
.DS_Store 6KB
sba_client_2_0
.DS_Store 6KB
pom.xml 2KB
src
.DS_Store 6KB
test
java
cn
codesheep
sba_client_2_0
SbaClient20ApplicationTests.java 358B
main
.DS_Store 6KB
resources
application.properties 236B
java
cn
codesheep
sba_client_2_0
SbaClient20Application.java 678B
.mvn
wrapper
maven-wrapper.properties 110B
maven-wrapper.jar 46KB
.gitignore 268B
sba_server_2_0
.DS_Store 6KB
pom.xml 2KB
src
test
java
cn
codesheep
sba_server_2_0
SbaServer20ApplicationTests.java 358B
main
resources
application-secure.properties 68B
application.properties 29B
java
cn
codesheep
sba_server_2_0
SbaServer20Application.java 2KB
.mvn
wrapper
maven-wrapper.properties 110B
maven-wrapper.jar 46KB
.gitignore 268B
共 20 条
- 1
资源评论
应用市场
- 粉丝: 456
- 资源: 3808
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功