fix(auth): correctly checks whether authN strategies are enabled before loading them
+ cleans up gql api on apps
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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!
|
||||
}
|
||||
|
||||
@@ -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 )
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user