https://github.com/d-band/auth-center
auth center with OAuth 2.0 & TOTP
https://github.com/d-band/auth-center
koa koa-orm koa-view koa2 oauth oauth2 oauth2-server totp
Last synced: about 1 month ago
JSON representation
auth center with OAuth 2.0 & TOTP
- Host: GitHub
- URL: https://github.com/d-band/auth-center
- Owner: d-band
- Created: 2016-03-15T15:43:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-09T03:17:32.000Z (over 4 years ago)
- Last Synced: 2024-10-02T09:06:58.314Z (7 months ago)
- Topics: koa, koa-orm, koa-view, koa2, oauth, oauth2, oauth2-server, totp
- Language: JavaScript
- Homepage:
- Size: 469 KB
- Stars: 3
- Watchers: 5
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Auth Center (OAuth2.0 + TOTP)
===[](https://www.npmjs.com/package/auth-center)
[](https://www.npmjs.com/package/auth-center)
[](https://travis-ci.org/d-band/auth-center)
[](https://coveralls.io/github/d-band/auth-center?branch=master)
[](https://david-dm.org/d-band/auth-center)### 安装
```
// 全局安装
npm i auth-center -g
// 非全局安装
npm i auth-center -S
```### 功能列表
- 配置方便、简单,UI简洁
- 多数据库支持:MySQL、Postgres、sqlite、mariadb
- session支持redis等
- OAuth2.0 授权码模式
- 密码验证增强(TOTP)
- 自带后台管理### 使用说明
> 完整配置文件参考:[config.js](./src/config.js)
#### 1. 采用命令行执行
```
$ auth-center -hUsage: auth-center [options] [command]
Commands:
init init config
start [options] start serverOptions:
-h, --help output usage information
-v, --version output the version number$ auth-center init
$ auth-center start -h
Usage: auth-center start [options]
start server
Options:
-h, --help output usage information
-p, --port server port
--config custom config path
--sync sync database to generate tables
--data init data with json file
```#### 2. 采用引入方式执行
```
const AuthServer = require('auth-center');const server = AuthServer({
domain: 'http://passport.example.com',
orm: {
database: 'db_auth',
username: 'root',
password: 'xxxx',
dialect: 'mysql',
host: '127.0.0.1',
port: 3306,
pool: {
maxConnections: 10,
minConnections: 0,
maxIdleTime: 30000
}
},
mail: {
from: '系统管理员 ',
host: 'smtp.example.com',
port: 465,
secure: true,
auth: {
user: '[email protected]',
pass: 'admin'
}
}
});server.listen(3000);
server.orm.database().sync({
force: true
}).then(() => { console.log('Sync done.'); });
```### 开发
```
git clone https://github.com/d-band/auth-center.git
cd auth-centernpm install
npm run dev
npm start
```### 参考链接
- https://github.com/oauthjs/express-oauth-server
- https://github.com/jaredhanson/oauth2orize
- https://tools.ietf.org/html/rfc6749#section-4
- https://tools.ietf.org/html/rfc6750
- http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html
- https://developer.github.com/v3/oauth/
- https://github.com/guyht/notp