We are not here because we are free .we are here because we are not free. 我們在這裡不是因為我們自由,我們在這裡是因為我們不自由。——《黑客帝國》 寫在開頭 在這個互聯網最美好的時代,隨著業務產品線的增多,業務應用平臺逐漸增多 ...
1. pom 加入 security
<!-- 加入密碼認證 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
2.加入配置類 SecuritySecureConfig
package org.fh.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import de.codecentric.boot.admin.server.config.AdminServerProperties;
/**
* 說明:SecuritySecure配置
* 作者:FH Admin
* from:fhadmin.cn
*/
@Configuration
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
private final 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.headers().frameOptions().disable();
http.authorizeRequests().antMatchers(adminContextPath + "/assets/**",adminContextPath + "/actuator/**").permitAll()
.antMatchers(adminContextPath + "/login").permitAll().anyRequest().authenticated().and().formLogin()
.loginPage(adminContextPath + "/login").successHandler(successHandler).and().logout()
.logoutUrl(adminContextPath + "/logout").and().httpBasic().and().csrf().disable();
}
}
3. 配置application.properties
#開啟安全認證 用戶名和密碼
spring.security.user.name=fhadmin
spring.security.user.password=root
spring.security.basic.enabled=true
當前最新框架組合方案-------------------------------------------------------------------------------------
(後臺框架 :springcloud 2021.0.1 + springcloud Alibaba 2021.0.1.0 + springboot 2.6.5 + flowable6.7.2 流程引擎 )
springcloud服務 (fhadmin.cn) 1 .nacos 阿裡註冊中心:官方eureka停止更新,目前比較好的取代者就是nacos 2. zipkin 跟蹤服務:分散式跟蹤日誌,基於記憶體存儲記錄 3 .gateway 網關路由服務:分發請求,統一管理過濾,結合 LoadBalancer負載均衡、 feign服務調用 4. springboot-admin 監控中心服務:統一界面管理,查看各個服務運行狀態 actuator健康檢查 5. sentinel 高可用流量管理框架: 以流量為切入點,限流、流量整形、熔斷降級、系統負載保護、熱點防護