當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringSecurity分布式整合之认证模块搭建
生活随笔
收集整理的這篇文章主要介紹了
SpringSecurity分布式整合之认证模块搭建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
認證服務
創建認證服務工程并導入jar包
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>springboot_security_jwt_rsa_parent</artifactId><groupId>com.leon</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>leon_auth_server</artifactId><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency><dependency><groupId>com.leon</groupId><artifactId>leon_common</artifactId><version>1.0-SNAPSHOT</version></dependency><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>5.1.47</version></dependency><dependency><groupId>org.mybatis.spring.boot</groupId><artifactId>mybatis-spring-boot-starter</artifactId><version>2.1.0</version></dependency></dependencies> </project>創建認證服務配置文件
server:port: 9001 spring:datasource:driver-class-name: com.mysql.jdbc.Driverurl: jdbc:mysql:///security_authorityusername: rootpassword: root mybatis:type-aliases-package: com.leon.domainconfiguration:map-underscore-to-camel-case: true logging:level:com.leon: debug rsa:key:pubKeyFile: D:\auth_key\id_key_rsa.pubpriKeyFile: D:\auth_key\id_key_rsa提供解析公鑰和私鑰的配置類
@Data @ConfigurationProperties(prefix = "leon.key") public class RsaKeyProperties {private String pubKeyPath;private String priKeyPath;private PublicKey publicKey;private PrivateKey privateKey;@PostConstructpublic void loadKey() throws Exception {publicKey = RsaUtils.getPublicKey(pubKeyPath);privateKey = RsaUtils.getPrivateKey(priKeyPath);} }創建認證服務啟動類
@SpringBootApplication @MapperScan("com.leon.mapper") @EnableConfigurationProperties(RsaKeyProperties.class) public class AuthApplication {public static void main(String[] args) {SpringApplication.run(AuthApplication.class, args);} }總結
以上是生活随笔為你收集整理的SpringSecurity分布式整合之认证模块搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: SpringSecurity分布式整合之
- 下一篇: SpringSecurity分布式整合之