springboot 单点登录_分布式单点登录框架--XXL-SSO

一、简介

62c5134d5642ce4536e9cbb2c1f0c013.png

1.1 概述

XXL-SSO 是一个分布式单点登录框架。只需要登录一次就可以访问所有相互信任的应用系统。 拥有"轻量级、分布式、跨域、Cookie+Token均支持、Web+APP均支持"等特性。现已开放源代码,开箱即用。

1.2 特性

  • 1、简洁:API直观简洁,可快速上手
  • 2、轻量级:环境依赖小,部署与接入成本较低
  • 3、单点登录:只需要登录一次就可以访问所有相互信任的应用系统
  • 4、分布式:接入SSO认证中心的应用,支持分布式部署
  • 5、HA:Server端与Client端,均支持集群部署,提高系统可用性
  • 6、跨域:支持跨域应用接入SSO认证中心
  • 7、Cookie+Token均支持:支持基于Cookie和基于Token两种接入方式,并均提供Sample项目
  • 8、Web+APP均支持:支持Web和APP接入
  • 9、实时性:系统登陆、注销状态,全部Server与Client端实时共享
  • 10、CS结构:基于CS结构,包括Server"认证中心"与Client"受保护应用"
  • 11、记住密码:未记住密码时,关闭浏览器则登录态失效;记住密码时,支持登录态自动延期,在自定义延期时间的基础上,原则上可以无限延期
  • 12、路径排除:支持自定义多个排除路径,支持Ant表达式,用于排除SSO客户端不需要过滤的路径

二、快速入门(基于Cookie)

基于Cookie,相关概念可参考 "章节 4.6"

2.1:源码编译

- xxl-sso-server:中央认证服务,支持集群- xxl-sso-core:Client端依赖- xxl-sso-samples:单点登陆Client端接入示例项目 - xxl-sso-web-sample-springboot:基于Cookie接入方式,供用户浏览器访问,springboot版本 - xxl-sso-token-sample-springboot:基于Token接入方式,常用于无法使用Cookie的场景使用,如APP、Cookie被禁用等,springboot版本

2.2 部署 "认证中心(SSO Server)"

项目名:xxl-sso-server

配置说明

配置文件位置:application.properties

……// redis 地址: 如 "{ip}"、"{ip}:{port}"、"{redis/rediss}://xxl-sso:{password}@{ip}:{port:6379}/{db}";多地址逗号分隔xxl.sso.redis.address=redis://127.0.0.1:6379// 登录态有效期窗口,默认24H,当登录态有效期窗口过半时,自动顺延一个周期xxl.sso.redis.expire.minite=1440

2.3 部署 "单点登陆Client端接入示例项目"

项目名:xxl-sso-web-sample-springboot

maven依赖

com.xuxueli xxl-sso-core ${最新稳定版}

配置 XxlSsoFilter

参考代码:com.xxl.sso.sample.config.XxlSsoConfig

@Beanpublic FilterRegistrationBean xxlSsoFilterRegistration() { // xxl-sso, redis init JedisUtil.init(xxlSsoRedisAddress); // xxl-sso, filter init FilterRegistrationBean registration = new FilterRegistrationBean(); registration.setName("XxlSsoWebFilter"); registration.setOrder(1); registration.addUrlPatterns("/*"); registration.setFilter(new XxlSsoWebFilter()); registration.addInitParameter(Conf.SSO_SERVER, xxlSsoServer); registration.addInitParameter(Conf.SSO_LOGOUT_PATH, xxlSsoLogoutPath); return registration;}

配置说明

配置文件位置:application.properties

……### xxl-sso (CLient端SSO配置)##### SSO Server认证中心地址(推荐以域名方式配置认证中心,本机可参考章节"2.5"修改host文件配置域名指向)xxl.sso.server=http://xxlssoserver.com:8080/xxl-sso-server##### 注销登陆path,值为Client端应用的相对路径xxl.sso.logout.path=/logout##### 路径排除Path,允许设置多个,且支持Ant表达式。用于排除SSO客户端不需要过滤的路径xxl-sso.excluded.paths=### redis // redis address, like "{ip}"、"{ip}:{port}"、"{redis/rediss}://xxl-sso:{password}@{ip}:{port:6379}/{db}";Multiple 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值