[oauth] start oauth auth_code server implementation

This commit is contained in:
les
2019-12-26 11:46:21 +01:00
parent c510541c50
commit 7ab81be418
17 changed files with 1631 additions and 838 deletions

View File

@@ -0,0 +1,19 @@
module.exports = (sequelize, DataTypes) => {
const OAuthClient = sequelize.define('oauth_client', {
client_id: {
type: DataTypes.STRING,
primaryKey: true
},
name: DataTypes.STRING,
scopes: DataTypes.STRING,
client_secret: DataTypes.STRING,
redirectUris: DataTypes.STRING
}, {})
OAuthClient.associate = function (models) {
OAuthClient.belongsTo(models.user)
}
return OAuthClient
}

View File

@@ -0,0 +1,18 @@
module.exports = (sequelize, DataTypes) => {
const OAuthCode = sequelize.define('oauth_code', {
authorizationCode: {
type: DataTypes.STRING,
primaryKey: true
},
scope: DataTypes.STRING,
redirect_uri: DataTypes.STRING
}, {})
OAuthCode.associate = function (models) {
OAuthCode.belongsTo(models.user)
OAuthCode.belongsTo(models.oauth_client)
}
return OAuthCode
}

View File

@@ -0,0 +1,15 @@
module.exports = (sequelize, DataTypes) => {
const OAuthToken = sequelize.define('oauth_token', {
access_token: DataTypes.STRING,
refresh_token: DataTypes.STRING,
scope: DataTypes.STRING,
}, {})
OAuthToken.associate = function (models) {
OAuthToken.belongsTo(models.user)
OAuthToken.belongsTo(models.oauth_client)
}
return OAuthToken
}