feat: auth self-registration config + gql grouping

This commit is contained in:
NGPixel
2018-06-25 02:44:40 -04:00
parent 49834461a6
commit 0afa65fa58
39 changed files with 104 additions and 50 deletions

View File

@@ -31,6 +31,9 @@ exports.up = knex => {
table.boolean('isEnabled').notNullable().defaultTo(false)
table.boolean('useForm').notNullable().defaultTo(false)
table.jsonb('config').notNullable()
table.boolean('selfRegistration').notNullable().defaultTo(false)
table.jsonb('domainWhitelist').notNullable()
table.jsonb('autoEnrollGroups').notNullable()
})
// COMMENTS ----------------------------
.createTable('comments', table => {

View File

@@ -22,13 +22,21 @@ module.exports = class Authentication extends Model {
title: {type: 'string'},
isEnabled: {type: 'boolean'},
useForm: {type: 'boolean'},
config: {type: 'object'}
config: {type: 'object'},
selfRegistration: {type: 'boolean'},
domainWhitelist: {type: 'object'},
autoEnrollGroups: {type: 'object'}
}
}
}
static async getEnabledStrategies() {
return WIKI.db.authentication.query().where({ isEnabled: true })
static async getStrategies() {
const strategies = await WIKI.db.authentication.query()
return strategies.map(str => ({
...str,
domainWhitelist: _.get(str.domainWhitelist, 'v', []),
autoEnrollGroups: _.get(str.autoEnrollGroups, 'v', [])
}))
}
static async refreshStrategiesFromDisk() {
@@ -46,7 +54,10 @@ module.exports = class Authentication extends Model {
config: _.reduce(strategy.props, (result, value, key) => {
_.set(result, value, '')
return result
}, {})
}, {}),
selfRegistration: false,
domainWhitelist: { v: [] },
autoEnrollGroups: { v: [] }
})
}
})