2018-03-04 02:48:28 +00:00
|
|
|
<template lang='pug'>
|
2018-06-10 00:11:00 +00:00
|
|
|
v-card(tile, :color='$vuetify.dark ? "grey darken-4" : "grey lighten-5"')
|
2018-06-04 04:41:29 +00:00
|
|
|
.pa-3.pt-4
|
|
|
|
.headline.primary--text Authentication
|
|
|
|
.subheading.grey--text Configure the authentication settings of your wiki
|
2018-06-10 00:11:00 +00:00
|
|
|
v-tabs(:color='$vuetify.dark ? "primary" : "grey lighten-4"', fixed-tabs, :slider-color='$vuetify.dark ? "white" : "primary"', show-arrows)
|
2018-06-04 04:41:29 +00:00
|
|
|
v-tab(key='settings'): v-icon settings
|
|
|
|
v-tab(v-for='strategy in activeStrategies', :key='strategy.key') {{ strategy.title }}
|
2018-03-04 02:48:28 +00:00
|
|
|
|
2018-06-04 04:41:29 +00:00
|
|
|
v-tab-item(key='settings', :transition='false', :reverse-transition='false')
|
|
|
|
v-card.pa-3(flat, tile)
|
2018-06-25 06:44:40 +00:00
|
|
|
.body-2.grey--text.text--darken-1 Select which authentication strategies to enable:
|
|
|
|
.caption.grey--text.pb-2 Some strategies require additional configuration in their dedicated tab (when selected).
|
2018-06-04 04:41:29 +00:00
|
|
|
v-form
|
2018-07-01 23:50:42 +00:00
|
|
|
v-checkbox.my-1(
|
2018-06-26 00:55:00 +00:00
|
|
|
v-for='strategy in strategies'
|
|
|
|
v-model='strategy.isEnabled'
|
|
|
|
:key='strategy.key'
|
|
|
|
:label='strategy.title'
|
|
|
|
color='primary'
|
2018-06-04 04:41:29 +00:00
|
|
|
:disabled='strategy.key === `local`'
|
|
|
|
hide-details
|
|
|
|
)
|
2018-03-06 04:13:20 +00:00
|
|
|
|
2018-06-04 04:41:29 +00:00
|
|
|
v-tab-item(v-for='(strategy, n) in activeStrategies', :key='strategy.key', :transition='false', :reverse-transition='false')
|
|
|
|
v-card.pa-3(flat, tile)
|
|
|
|
v-form
|
|
|
|
v-subheader.pl-0 Strategy Configuration
|
|
|
|
.body-1.ml-3(v-if='!strategy.config || strategy.config.length < 1') This strategy has no configuration options you can modify.
|
2018-07-01 23:50:42 +00:00
|
|
|
template(v-else, v-for='cfg in strategy.config')
|
|
|
|
v-select(
|
|
|
|
v-if='cfg.value.type === "string" && cfg.value.enum'
|
|
|
|
:items='cfg.value.enum'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.key | startCase'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
prepend-icon='settings_applications'
|
2018-06-25 06:44:40 +00:00
|
|
|
)
|
2018-07-01 23:50:42 +00:00
|
|
|
v-switch(
|
|
|
|
v-else-if='cfg.value.type === "boolean"'
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.key | startCase'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
color='primary'
|
|
|
|
prepend-icon='settings_applications'
|
|
|
|
)
|
|
|
|
v-text-field(
|
|
|
|
v-else
|
|
|
|
:key='cfg.key'
|
|
|
|
:label='cfg.key | startCase'
|
|
|
|
v-model='cfg.value.value'
|
|
|
|
prepend-icon='settings_applications'
|
|
|
|
)
|
2018-07-08 05:12:43 +00:00
|
|
|
v-divider.mt-3
|
2018-06-04 04:41:29 +00:00
|
|
|
v-subheader.pl-0 Registration
|
2018-06-26 00:55:00 +00:00
|
|
|
.pr-3
|
|
|
|
v-switch.ml-3(
|
|
|
|
v-model='strategy.selfRegistration'
|
|
|
|
label='Allow self-registration'
|
|
|
|
color='primary'
|
|
|
|
hint='Allow any user successfully authorized by the strategy to access the wiki.'
|
|
|
|
persistent-hint
|
2018-06-25 06:44:40 +00:00
|
|
|
)
|
2018-06-26 00:55:00 +00:00
|
|
|
v-select.ml-3(
|
|
|
|
label='Limit to specific email domains'
|
|
|
|
v-model='strategy.domainWhitelist'
|
|
|
|
prepend-icon='mail_outline'
|
|
|
|
persistent-hint
|
|
|
|
deletable-chips
|
|
|
|
clearable
|
|
|
|
multiple
|
|
|
|
chips
|
|
|
|
tags
|
|
|
|
)
|
|
|
|
v-select.ml-3(
|
|
|
|
:items='groups'
|
|
|
|
item-text='name'
|
|
|
|
item-value='id'
|
|
|
|
label='Assign to group'
|
|
|
|
v-model='strategy.autoEnrollGroups'
|
|
|
|
prepend-icon='people'
|
|
|
|
hint='Automatically assign new users to these groups.'
|
|
|
|
persistent-hint
|
|
|
|
deletable-chips
|
|
|
|
autocomplete
|
|
|
|
clearable
|
|
|
|
multiple
|
|
|
|
chips
|
|
|
|
)
|
2018-06-04 04:41:29 +00:00
|
|
|
|
2018-06-10 00:11:00 +00:00
|
|
|
v-card-chin
|
2018-06-26 00:55:00 +00:00
|
|
|
v-btn(color='primary', @click='save')
|
2018-06-04 04:41:29 +00:00
|
|
|
v-icon(left) chevron_right
|
2018-06-26 02:04:47 +00:00
|
|
|
span Apply Configuration
|
2018-06-04 04:41:29 +00:00
|
|
|
v-spacer
|
|
|
|
v-btn(icon, @click='refresh')
|
|
|
|
v-icon.grey--text refresh
|
2018-03-06 04:13:20 +00:00
|
|
|
|
2018-03-04 02:48:28 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2018-03-12 04:09:54 +00:00
|
|
|
import _ from 'lodash'
|
2018-06-04 04:41:29 +00:00
|
|
|
|
2018-06-26 00:55:00 +00:00
|
|
|
import groupsQuery from 'gql/admin/auth/auth-query-groups.gql'
|
2018-06-25 06:44:40 +00:00
|
|
|
import strategiesQuery from 'gql/admin/auth/auth-query-strategies.gql'
|
|
|
|
import strategiesSaveMutation from 'gql/admin/auth/auth-mutation-save-strategies.gql'
|
2018-03-06 01:53:24 +00:00
|
|
|
|
2018-03-04 02:48:28 +00:00
|
|
|
export default {
|
2018-07-01 23:50:42 +00:00
|
|
|
filters: {
|
|
|
|
startCase(val) { return _.startCase(val) }
|
|
|
|
},
|
2018-03-04 02:48:28 +00:00
|
|
|
data() {
|
|
|
|
return {
|
2018-06-26 00:55:00 +00:00
|
|
|
groups: [],
|
|
|
|
strategies: []
|
2018-03-04 02:48:28 +00:00
|
|
|
}
|
2018-03-06 01:53:24 +00:00
|
|
|
},
|
2018-03-12 04:09:54 +00:00
|
|
|
computed: {
|
2018-06-04 04:41:29 +00:00
|
|
|
activeStrategies() {
|
2018-06-26 00:55:00 +00:00
|
|
|
return _.filter(this.strategies, 'isEnabled')
|
2018-03-12 04:09:54 +00:00
|
|
|
}
|
|
|
|
},
|
2018-06-04 04:41:29 +00:00
|
|
|
methods: {
|
|
|
|
async refresh() {
|
|
|
|
await this.$apollo.queries.strategies.refetch()
|
|
|
|
this.$store.commit('showNotification', {
|
|
|
|
message: 'List of strategies has been refreshed.',
|
|
|
|
style: 'success',
|
|
|
|
icon: 'cached'
|
|
|
|
})
|
|
|
|
},
|
2018-06-26 00:55:00 +00:00
|
|
|
async save() {
|
2018-06-04 04:41:29 +00:00
|
|
|
this.$store.commit(`loadingStart`, 'admin-auth-savestrategies')
|
|
|
|
await this.$apollo.mutate({
|
|
|
|
mutation: strategiesSaveMutation,
|
|
|
|
variables: {
|
2018-06-26 00:55:00 +00:00
|
|
|
strategies: this.strategies.map(str => _.pick(str, [
|
|
|
|
'isEnabled',
|
|
|
|
'key',
|
|
|
|
'config',
|
|
|
|
'selfRegistration',
|
|
|
|
'domainWhitelist',
|
|
|
|
'autoEnrollGroups'
|
2018-07-01 23:50:42 +00:00
|
|
|
])).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: cfg.value.value}))}))
|
2018-03-19 03:12:56 +00:00
|
|
|
}
|
2018-06-04 04:41:29 +00:00
|
|
|
})
|
2018-06-26 00:55:00 +00:00
|
|
|
this.$store.commit('showNotification', {
|
2018-06-26 02:04:47 +00:00
|
|
|
message: 'Authentication configuration saved successfully.',
|
2018-06-26 00:55:00 +00:00
|
|
|
style: 'success',
|
|
|
|
icon: 'check'
|
|
|
|
})
|
2018-06-04 04:41:29 +00:00
|
|
|
this.$store.commit(`loadingStop`, 'admin-auth-savestrategies')
|
2018-03-06 01:53:24 +00:00
|
|
|
}
|
2018-03-06 04:13:20 +00:00
|
|
|
},
|
2018-06-04 04:41:29 +00:00
|
|
|
apollo: {
|
|
|
|
strategies: {
|
|
|
|
query: strategiesQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
2018-07-01 23:50:42 +00:00
|
|
|
update: (data) => _.cloneDeep(data.authentication.strategies).map(str => ({...str, config: str.config.map(cfg => ({...cfg, value: JSON.parse(cfg.value)}))})),
|
2018-06-04 04:41:29 +00:00
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-refresh')
|
|
|
|
}
|
2018-06-26 00:55:00 +00:00
|
|
|
},
|
|
|
|
groups: {
|
|
|
|
query: groupsQuery,
|
|
|
|
fetchPolicy: 'network-only',
|
|
|
|
update: (data) => data.groups.list,
|
|
|
|
watchLoading (isLoading) {
|
|
|
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-auth-groups-refresh')
|
|
|
|
}
|
2018-03-06 04:13:20 +00:00
|
|
|
}
|
2018-03-04 02:48:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
|
|
|
|
</style>
|