客户端1的配置
🍎🍏💜👛🍇🍑🍐🍍🍌🍉🍈🍓⏰👮👮♀🥕🚑🚙🌈📷🎯📧🤡💙💑🗂🏝🌾🏤
1.创建一个可以正常启动的SpringBoot工程
- github代码地址:branches_makaixuan(分支)
🔗https://github.com/MaKaixuanGitHub/SpringBootThemeleaf.git
- Login用户:
username:admin(暂时不要)
password:1234(暂时不要)
- 客户端Tomcat server地址:
🔗http://localhost:8081
2.授权证客户端配置
- application.yml
# Tomcat端口号
server:
port: 8081
servlet:
session:
cookie:
name: OAUTH2-CLIENT-SESSIONID01
# security授权认证配置
security:
oauth2:
client:
client-id: admin
client-secret: 112233
user-authorization-uri: http://localhost:8080/oauth/authorize
access-token-uri: http://localhost:8080/oauth/token
resource:
jwt:
key-uri: http://localhost:8080/oauth/token_key
①:端口号指定: port: 8081
②:cookie-name:OAUTH2-CLIENT-SESSIONID01~n
③:客户端认证ID:client-id:任意
④:客户端认证密码:client-secret: 任意
⑤:客户端认证URL:user-authorization-uri: http://localhost:8080/oauth/authorize
⑥:授权Token令牌URL:access-token-uri: http://localhost:8080/oauth/token
⑦:jwtKey:key-uri: http://localhost:8080/oauth/token_key
- SpringBoot初始化启动类上加一个单点登录有效注解
@EnableOAuth2Sso
pom.xml依赖
<!-- Spring-security 依赖-->
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-security</artifactId>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.0</version>
</dependency>
</dependencies>
<!-- Spring-cloud 依赖-->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Greenwich.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>