Azard / Egg Oauth2 Server
Licence: mit
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Egg Oauth2 Server
Egg Cancan
cancancan like authorization plugin for Egg.js
Stars: ✭ 47 (-72.99%)
Mutual labels: egg, eggjs, egg-plugin
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (-32.76%)
Mutual labels: egg, eggjs, egg-plugin
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+8.05%)
Mutual labels: egg, eggjs, egg-plugin
egg-parameters
Merge all parameters (ctx.params, ctx.request.query, ctx.request.body) into ctx.params like Rails application.
Stars: ✭ 24 (-86.21%)
Mutual labels: egg, egg-plugin, eggjs
egg-rbac
Role Based Access Control for eggjs
Stars: ✭ 32 (-81.61%)
Mutual labels: egg, egg-plugin, eggjs
Egg 24time
A Twitter-like news and social server for Egg. 微信小程序社区全栈解决方案
Stars: ✭ 493 (+183.33%)
Mutual labels: egg, eggjs, egg-plugin
Egg Authz
egg-authz is an authorization middleware for Egg.js based on Casbin
Stars: ✭ 50 (-71.26%)
Mutual labels: egg, eggjs, egg-plugin
Cierge
🗝️ Passwordless OIDC authentication done right
Stars: ✭ 1,245 (+615.52%)
Mutual labels: oauth2, oauth2-server
Ngx Api Utils
ngx-api-utils is a lean library of utilities and helpers to quickly integrate any HTTP API (REST, Ajax, and any other) with Angular.
Stars: ✭ 92 (-47.13%)
Mutual labels: npm-package, oauth2
Flask Oauthlib
YOU SHOULD USE https://github.com/lepture/authlib
Stars: ✭ 1,429 (+721.26%)
Mutual labels: oauth2, oauth2-server
Node Oauth2 Server Mongo Example
Working oauth2 server with mongodb storage and minimal configuration
Stars: ✭ 76 (-56.32%)
Mutual labels: oauth2, oauth2-server
Egg Mongo Native
MongoDB egg.js plugin using native driver.
Stars: ✭ 69 (-60.34%)
Mutual labels: eggjs, egg-plugin
Django Oauth2 Server
OAuth2 server written in Python with Django
Stars: ✭ 108 (-37.93%)
Mutual labels: oauth2, oauth2-server
Node Oauth2 Server Example
Working oauth2 server with minimal configuration
Stars: ✭ 115 (-33.91%)
Mutual labels: oauth2, oauth2-server
egg-oauth2-server
Chinese Example | 中文样例教程(注意:文章里使用的是该插件 v1.x 版本,部分 API 名称有变化,主要流程一致)
egg-oauth2-server
is a module that easily adds oauth2 capability to egg-based servers.
- egg 2.x use egg-oauth2-server latest (Node >= 8.0.0)
- egg 1.x use egg-oauth2-server 2.0.x (Node >= 6.0.0)
Install
$ npm i egg-oauth2-server --save
Usage
// {app_root}/config/plugin.js
exports.oAuth2Server = {
enable: true,
package: 'egg-oauth2-server',
};
// {app_root}/app/router.js
app.all('/user/token', app.oAuth2Server.token());
app.get('/user/authorize', app.oAuth2Server.authorize(), 'user.code');
app.get('/user/authenticate', app.oAuth2Server.authenticate(), 'user.authenticate');
// `ctx.state.oauth` has token or code data after middleware for controller.
// {app_root}/config/config.default.js
module.exports = config => {
const exports = {};
exports.oAuth2Server = {
debug: config.env === 'local',
grants: [ 'password' ],
};
return exports;
};
See test/fixtures/apps/oauth2-server-test/config/config.unittest.js for reference.
// {app_root}/app/extend/oauth.js
// or {app_root}/app/extend/oauth.ts
'use strict';
// need implement some follow functions
module.exports = app => {
class Model {
constructor(ctx) {}
async getClient(clientId, clientSecret) {}
async getUser(username, password) {}
async saveAuthorizationCode(code, client, user) {}
async getAuthorizationCode(authorizationCode) {}
async revokeAuthorizationCode(code) {}
async saveToken(token, client, user) {}
async getAccessToken(bearerToken) {}
async revokeToken(token) {}
}
return Model;
};
For full description, check out https://www.npmjs.com/package/oauth2-server.
Examples
A simple password-mode OAuth 2.0 server. Full code at test/fixtures/apps/oauth2-server-test/app/extend/oauth.js
app.oauth.token()
lifecycle
password mode getClient
--> getUser
--> saveToken
app.oauth.authenticate()
lifecycle
password mode Only getAccessToken
app.oauth.authorize()
lifecycle
authorization_code mode getClient
--> getUser
--> saveAuthorizationCode
app.oauth.token()
lifecycle
authorization_code mode getClient
--> getAuthorizationCode
--> revokeAuthorizationCode
--> saveToken
app.oauth.authenticate()
lifecycle
authorization_code mode Only getAccessToken
Questions & Suggestions
Please open an issue. PRs are welcomed too.
License
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].