diff --git a/packages/xo-server-auth-github/src/index.js b/packages/xo-server-auth-github/src/index.js index c2006d34d..c427237db 100644 --- a/packages/xo-server-auth-github/src/index.js +++ b/packages/xo-server-auth-github/src/index.js @@ -2,12 +2,33 @@ import {Strategy} from 'passport-github' // =================================================================== +export const configurationSchema = { + type: 'object', + properties: { + clientID: { + type: 'string' + }, + clientSecret: { + type: 'string' + } + }, + required: ['clientID', 'clientSecret'] +} + +// =================================================================== + class AuthGitHubXoPlugin { - constructor (conf) { + constructor (xo) { + this._xo = xo + } + + configure (conf) { this._conf = conf } - load (xo) { + load () { + const {_xo: xo} = this + xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => { try { done(null, await xo.registerUser('github', profile.username)) @@ -20,4 +41,4 @@ class AuthGitHubXoPlugin { // =================================================================== -export default conf => new AuthGitHubXoPlugin(conf) +export default ({xo}) => new AuthGitHubXoPlugin(xo)