feat: auth strategies over GraphQL + svg loading
This commit is contained in:
@@ -14,7 +14,7 @@ module.exports = {
|
||||
useForm: false,
|
||||
props: ['clientId', 'clientSecret', 'callbackURL'],
|
||||
init (passport, conf) {
|
||||
passport.use('windowslive',
|
||||
passport.use('microsoft',
|
||||
new WindowsLiveStrategy({
|
||||
clientID: conf.clientId,
|
||||
clientSecret: conf.clientSecret,
|
||||
|
@@ -10,6 +10,7 @@ const _ = require('lodash')
|
||||
const typeDefs = fs.readFileSync(path.join(wiki.SERVERPATH, 'schemas/types.graphql'), 'utf8')
|
||||
|
||||
const DateScalar = require('../schemas/scalar-date')
|
||||
const AuthenticationResolvers = require('../schemas/resolvers-authentication')
|
||||
const CommentResolvers = require('../schemas/resolvers-comment')
|
||||
const DocumentResolvers = require('../schemas/resolvers-document')
|
||||
const FileResolvers = require('../schemas/resolvers-file')
|
||||
@@ -21,6 +22,7 @@ const TranslationResolvers = require('../schemas/resolvers-translation')
|
||||
const UserResolvers = require('../schemas/resolvers-user')
|
||||
|
||||
const resolvers = _.merge(
|
||||
AuthenticationResolvers,
|
||||
CommentResolvers,
|
||||
DocumentResolvers,
|
||||
FileResolvers,
|
||||
|
40
server/schemas/resolvers-authentication.js
Normal file
40
server/schemas/resolvers-authentication.js
Normal file
@@ -0,0 +1,40 @@
|
||||
const _ = require('lodash')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
/* global wiki */
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
authentication(obj, args, context, info) {
|
||||
switch (args.mode) {
|
||||
case 'active':
|
||||
let strategies = _.chain(wiki.auth.strategies).map(str => {
|
||||
return {
|
||||
key: str.key,
|
||||
title: str.title,
|
||||
useForm: str.useForm
|
||||
}
|
||||
}).sortBy(['title']).value()
|
||||
let localStrategy = _.remove(strategies, str => str.key === 'local')
|
||||
return _.concat(localStrategy, strategies)
|
||||
case 'all':
|
||||
|
||||
break
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
},
|
||||
Mutation: {},
|
||||
AuthenticationProvider: {
|
||||
icon (ap, args) {
|
||||
return fs.readFileAsync(path.join(wiki.ROOTPATH, `assets/svg/auth-icon-${ap.key}.svg`), 'utf8').catch(err => {
|
||||
if (err.code === 'ENOENT') {
|
||||
return null
|
||||
}
|
||||
throw err
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
@@ -32,10 +32,11 @@ interface Base {
|
||||
# TYPES
|
||||
|
||||
type AuthenticationProvider {
|
||||
id: String!
|
||||
key: String!
|
||||
useForm: Boolean!
|
||||
title: String!
|
||||
props: [String]
|
||||
icon: String
|
||||
config: String
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user