diff --git a/modules/apps/graph/resolvers/apps.js b/modules/apps/graph/resolvers/apps.js index f0e463bd7..44c8b2365 100644 --- a/modules/apps/graph/resolvers/apps.js +++ b/modules/apps/graph/resolvers/apps.js @@ -19,26 +19,5 @@ module.exports = { } }, Mutation: { - async appAuthorize( parent, args, context, info ) { - await validateServerRole( context, 'server:user' ) - await validateScopes( context.scopes, 'apps:authorize' ) // TODO - - // Implicit grant flow: returns the token directly - // let token = await createAppToken( { userId: context.userId, appId: args.appId } ) - // return token - - // TODO: Implement authorization code grant - let accessCode = await createAuthorizationCode( { userId: contex.userId, appId: args.appId, challenge: args.challenge } ) - return accessCode - }, - async appGetToken( parent, args, context, info ) { - - let result = await exchangeAuthorizationCodeForToken( { appId: args.appId, appSecret: args.appSecret, accessCode: args.accessCode, challenge: args.challenge } ) - // args.appId, args.appSecret, args.accessCode - - }, - async appRefreshToken( parent, args, context, info ) { - // TODO - } } } \ No newline at end of file diff --git a/modules/apps/graph/schemas/auth.graphql b/modules/apps/graph/schemas/auth.graphql index 4bd678689..b82dace65 100644 --- a/modules/apps/graph/schemas/auth.graphql +++ b/modules/apps/graph/schemas/auth.graphql @@ -31,26 +31,3 @@ type AuthStrategy { url: String!, color: String } -extend type Mutation { - """ - Authorizes an app on behalf of a user. Returns an access code that can be exchanged - by the application for an api token. - """ - appAuthorize( appId: String!, challenge: String! ): String! - """ - Exchanges an access code for an api token. - """ - appGetToken( appId: String!, appSecret: String!, accesCode: String!, challenge: String! ): AppTokenResponse! - """ - Refreshes an expired token. - """ - appRefreshToken( appId: String, appSecret:String!, refreshToken: String! ): AppTokenResponse! -} - -type AppTokenResponse { - """ - The actual bearer token. - """ - token: String! - refreshToken: String! -} diff --git a/modules/apps/index.js b/modules/apps/index.js index 0ab426ed5..0195abecb 100644 --- a/modules/apps/index.js +++ b/modules/apps/index.js @@ -74,13 +74,17 @@ exports.init = ( app, options ) => { // Strategies initialisation & listing - let githubStrategy = require( './strategies/github' )( app, session, sessionAppId, finalizeAuth ) - authStrategies.push( githubStrategy ) + if ( process.env.STRATEGY_GITHUB === 'true' ) { + let githubStrategy = require( './strategies/github' )( app, session, sessionAppId, finalizeAuth ) + authStrategies.push( githubStrategy ) + } - let googStrategy = require( './strategies/google' )( app, session, sessionAppId, finalizeAuth ) - authStrategies.push( googStrategy ) + if ( process.env.STRATEGY_GOOGLE === 'true' ) { + let googStrategy = require( './strategies/google' )( app, session, sessionAppId, finalizeAuth ) + authStrategies.push( googStrategy ) + } - if ( process.env.STRATEGY_LOCAL ) { + if ( process.env.STRATEGY_LOCAL === 'true' ) { let localStrategy = require( './strategies/local' )( app, session, sessionAppId, finalizeAuth ) authStrategies.push( localStrategy ) }