From b31f55063dd4814a20db7f12b2ee8c1f13fa9c65 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Thu, 8 Oct 2015 13:56:03 +0200 Subject: [PATCH] New plugin API. --- packages/xo-server-auth-google/src/index.js | 31 +++++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/packages/xo-server-auth-google/src/index.js b/packages/xo-server-auth-google/src/index.js index b01ca6ec9..41a159cc9 100644 --- a/packages/xo-server-auth-google/src/index.js +++ b/packages/xo-server-auth-google/src/index.js @@ -2,14 +2,39 @@ import {OAuth2Strategy as Strategy} from 'passport-google-oauth' // =================================================================== +export const configurationSchema = { + type: 'object', + properties: { + callbackURL: { + type: 'string', + description: 'Must be exactly the same as specified on the Google developer console.' + }, + clientID: { + type: 'string' + }, + clientSecret: { + type: 'string' + } + }, + required: ['callbackURL', 'clientID', 'clientSecret'] +} + +// =================================================================== + class AuthGoogleXoPlugin { - constructor (conf) { + constructor (xo) { + this._xo = xo + } + + configure (conf) { conf.scope = 'https://www.googleapis.com/auth/plus.login' this._conf = conf } - load (xo) { + load () { + const {_xo: xo} = this + xo.registerPassportStrategy(new Strategy(this._conf, async (accessToken, refreshToken, profile, done) => { try { console.log(profile) @@ -23,4 +48,4 @@ class AuthGoogleXoPlugin { // =================================================================== -export default conf => new AuthGoogleXoPlugin(conf) +export default ({xo}) => new AuthGoogleXoPlugin(xo)