SpringSecurity整合SSO单点登录

志不强者智不达,言不信者行不果。这篇文章主要讲述SpringSecurity整合SSO单点登录相关的知识,希望能为你提供帮助。
SpringSecurity整合SSO单点登录

欢迎关注博主公众号「java大师」, 专注于分享Java领域干货文章http://www.javaman.cn/sb2/springsecurity-sso
------
1、什么是单点登录?举个简单的例子,在日常开发中,我们经常需要用带gitee码云,在登录的时候不一定需要注册,可以使用第三方账号进行登录,比如github、微博账号或者微信扫码等等,授权访问等等,这些都属于单点登录

例如:登录码云、微信扫码授权登录

【SpringSecurity整合SSO单点登录】上图的gitee就是咱们要访问的网站,点击使用微信登录,扫描二维码就是使用微信授权单点登录码云
那上面究竟是怎么实现的呢,做个简单的例子给大家讲解一下具体的实现步骤2、单点登录实现代码2.1、单点登录的服务端实现2.1.1、pom.xml文件
< ?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
< modelVersion> 4.0.0< /modelVersion>
< parent>
< groupId> org.springframework.boot< /groupId>
< artifactId> spring-boot-starter-parent< /artifactId>
< version> 2.2.6.RELEASE< /version>
< relativePath/> < !-- lookup parent from repository -->
< /parent>
< groupId> com.dashi< /groupId>
< artifactId> springsecurity-oauth< /artifactId>
< version> 0.0.1-SNAPSHOT< /version>
< name> springsecurity-oauth< /name>
< description> Demo project for Spring Boot< /description>
< properties>
< java.version> 1.8< /java.version>
< spring-cloud.version> Greenwich.SR5< /spring-cloud.version>
< /properties>
< dependencies>
< dependency>
< groupId> org.springframework.cloud< /groupId>
< artifactId> spring-cloud-starter-oauth2< /artifactId>
< /dependency>

< !--security依赖-->
< dependency>
< groupId> org.springframework.cloud< /groupId>
< artifactId> spring-cloud-starter-security< /artifactId>
< /dependency>

< !--boot依赖-->
< dependency>
< groupId> org.springframework.boot< /groupId>
< artifactId> spring-boot-starter< /artifactId>
< /dependency>
< !--boot依赖-->
< dependency>
< groupId> org.springframework.boot< /groupId>
< artifactId> spring-boot-starter-web< /artifactId>
< /dependency>
< !--test依赖-->
< dependency>
< groupId> org.springframework.boot< /groupId>
< artifactId> spring-boot-starter-test< /artifactId>
< scope> test< /scope>
< /dependency>

< !--redis依赖 -->
< dependency>
< groupId> org.springframework.boot< /groupId>
< artifactId> spring-boot-starter-data-redis< /artifactId>
< /dependency>
< !--commons-pool2对象依赖 -->
< dependency>
< groupId> org.apache.commons< /groupId>
< artifactId> commons-pool2< /artifactId>
< /dependency>
< /dependencies>

< build>
< plugins>
< plugin>
< groupId> org.springframework.boot< /groupId>
< artifactId> spring-boot-maven-plugin< /artifactId>
< /plugin>
< /plugins>
< /build>
< dependencyManagement>
< dependencies>
< dependency>
< groupId> org.springframework.cloud< /groupId>
< artifactId> spring-cloud-dependencies< /artifactId>
< version> $spring-cloud.version< /version>
< type> pom< /type>
< scope> import< /scope>
< /dependency>
< /dependencies>
< /dependencyManagement>
< /project>

2.1.2、springsecurity配置文件
package com.dashi.springsecurityoauth.config;

import org.springframework.context.

    推荐阅读