Code Monkey home page Code Monkey logo

sso's Introduction

简介

该项目的初衷是为了解决公司内部多个系统多套账户的登录体系、微服务平台架构以及对外提供的开放平台的认证和鉴权问题。后来整理了一下打算写成一个通用的项目。

项目分成2部分,sso-serversso-client,前者需要单独部署用,后者用于客户端(后端,默认使用feign调用,所以需要微服务的支持以及一个注册中心,后续看情况添加httpclient支持),目前通过restful api的形式提供服务,所以没有前端界面,仅提供swagger接口文档。

目录

Sso Server

该项目需要单独部署,用于提供身份认证和鉴权服务,默认提供了一些配置和可插拔接口,如果无法满足可以自定义配置和接口实现。

接口文档:${scheme}://${host}:${port}/${context}/swagger-ui.html

[必选配置]

[可选配置]

Sso Client

项目依赖:

<dependency>
    <groupId>com.xjbg</groupId>
    <artifactId>sso-client</artifactId>
    <version>${sso-client-version}</version>
</dependency>

api

[必选配置]

[可选配置]

  • cas
    • SessionStorage 用于保存ticket和session的关系,默认用hashmap维护session,用于单点登出,可选方案(基于redis):spring-session和shiro-session
    • SingleSignOutHttpSessionListener 使用hashmapSessionStorage时必须配置该监听器用于移除过期的session避免oom

Cas

  1. cas登录流程:引导至登录页提交用户密码获取tgt->用tgt获取ticket->使用ticket调用接口。(注:ticket只能使用一次不论成功与否,成功之后客户端会在session维持登录状态不需要重复获取)
  2. cas代理模式:代理端每次调用接口前都需要使用tgt获取proxyTicket,使用proxyTicket调用被代理端(用于纯后端交互的场景,不涉及session和cookie)。 (注:为了兼容微服务和简化流程,rest风格的cas代理模式跟2.0协议有所不同)
  3. HttpStatus为403时为ticket无效或者拒绝访问

OAuth

HttpStatus为401时为未授权或者权限(scope)不够

grandType refreshToken support
授权码模式(authorization code)
简化模式(implicit) ×
密码模式(resource owner password credentials) ×
客户端模式(client credentials) ×

(注:grandType和responseType见枚举类:GrandTypeResponseType)

Response Code

返回码 说明
B1009 应用不支持此授权模式或授权模式不对
B10011 redirect uri的值与后台配置(注册时应用的回调uri)不一致
401 未授权或者权限不够
500 系统异常

Todo

  1. 后续有需求或者有空继续DeveloperAdministrator功能的开发(应该是没空了。。)。
  2. 日志脱敏

sso's People

Contributors

kestrong avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.