GithubHelp home page GithubHelp logo

jammyjaccy / go-oauth2-sso Goto Github PK

View Code? Open in Web Editor NEW

This project forked from janwenjohn/go-oauth2-sso

0.0 2.0 0.0 19 KB

oauth2&sso server written by golang

Home Page: http://heartlifes.com

License: Apache License 2.0

Go 100.00%

go-oauth2-sso's Introduction

关于

这是一个用go写的,实现了OAuth2协议及SSO单点登录协议的基础框架,可用于在此基础上搭建基于SSO单点登录的OAuth2受控安全协议

接口发布

oauth2

test.yourhost.com:3000/oauth/authorize?client_id=abc&response_type=code&redirect_uri=http://www.baidu.com&scope=read test.yourhost.com:3000/oauth/token?client_id=abc&client_secret=abc&grant_type=authorization_code&code=lM4RU738&redirect_uri=http://www.baidu.com test.yourhost.com:3000/oauth/check?access_token=xxxxx&username=xxxxxx

sso

test.yourhost.com:5000/login?service=http://www.baidu.com test.yourhost.com:5000/serviceValidate?service=http://www.baidu.com&ticket=xxxxxxxxx

技术

选用以下框架: go-martini martini-contrib go-redis go-sql-driver

配置

sso

ST有效期时间:constant.go:SERVICE_TICKET_TIME_TO_LIVE TGT有效期时间:constant.go:TICKET_GRANTING_TICKET_TIME_TO_LIVE cookie domain:constant.go:COOKIE_DOMAIN 日志目录:config.go:LOG_FILE redis连接信息:config.go:Redis_Config

oauth2

code超时时间:constant.go:REDIS_CODE_TIMEOUT token有效时间:constant.go:TOKEN_VALIDATE_TIME_IN_SECONDS 日志目录:config.go:LOG_FILE redis连接信息:config.go:Redis_Config mysql连接信息:config.go:DB_Config 服务器路径配置:config.go:Server_Config

数据库

sso

只使用redis存储数据 存储数据包括:

  1. ST: ST_xxxxxxxxxxxxxxx
  2. TGT: TGT_xxxxxxxxxxxxxx tgt及st超时时间使用redis ttl机制

oauth2

使用redis和mysql存储数据 其中,redis存储包括:

  1. code: OAUTH_CODE_xxxxxxxx code超时时间使用redis ttl机制 mysql存储包括: oauth_client_details: CREATE TABLE oauth_client_details ( client_id varchar(100) NOT NULL, client_secret varchar(255) NOT NULL, redirect_uri varchar(255) DEFAULT NULL, scope varchar(10) DEFAULT NULL, client_name varchar(255) DEFAULT NULL, client_logo varchar(255) DEFAULT NULL, PRIMARY KEY (client_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

oauth_token: CREATE TABLE oauth_token ( token varchar(255) NOT NULL, client_id varchar(100) NOT NULL, username varchar(100) NOT NULL, expiration varchar(100) DEFAULT NULL, token_type varchar(20) DEFAULT NULL, token_scope varchar(20) DEFAULT NULL, refresh_token varchar(255) DEFAULT NULL, PRIMARY KEY (token) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;

go-oauth2-sso's People

Contributors

janwenjohn avatar

Watchers

James Cloos avatar jammyjaccy 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.