feat: enforce 2fa admin setting + hide local on login screen

This commit is contained in:
NGPixel 2020-07-05 23:55:11 -04:00
parent b8d15915cd
commit 1ced9649c7
5 changed files with 25 additions and 6 deletions

View File

@ -278,6 +278,7 @@ export default {
mutation: gql` mutation: gql`
mutation ( mutation (
$authAutoLogin: Boolean $authAutoLogin: Boolean
$authEnforce2FA: Boolean
$authHideLocal: Boolean $authHideLocal: Boolean
$authLoginBgUrl: String $authLoginBgUrl: String
$authJwtAudience: String $authJwtAudience: String
@ -298,6 +299,7 @@ export default {
site { site {
updateConfig( updateConfig(
authAutoLogin: $authAutoLogin, authAutoLogin: $authAutoLogin,
authEnforce2FA: $authEnforce2FA,
authHideLocal: $authHideLocal, authHideLocal: $authHideLocal,
authLoginBgUrl: $authLoginBgUrl, authLoginBgUrl: $authLoginBgUrl,
authJwtAudience: $authJwtAudience, authJwtAudience: $authJwtAudience,
@ -327,6 +329,7 @@ export default {
`, `,
variables: { variables: {
authAutoLogin: _.get(this.config, 'authAutoLogin', false), authAutoLogin: _.get(this.config, 'authAutoLogin', false),
authEnforce2FA: _.get(this.config, 'authEnforce2FA', false),
authHideLocal: _.get(this.config, 'authHideLocal', false), authHideLocal: _.get(this.config, 'authHideLocal', false),
authLoginBgUrl: _.get(this.config, 'authLoginBgUrl', ''), authLoginBgUrl: _.get(this.config, 'authLoginBgUrl', ''),
authJwtAudience: _.get(this.config, 'authJwtAudience', ''), authJwtAudience: _.get(this.config, 'authJwtAudience', ''),
@ -377,6 +380,7 @@ export default {
site { site {
config { config {
authAutoLogin authAutoLogin
authEnforce2FA
authHideLocal authHideLocal
authLoginBgUrl authLoginBgUrl
authJwtAudience authJwtAudience

View File

@ -18,7 +18,7 @@
v-list.elevation-1.radius-7(nav) v-list.elevation-1.radius-7(nav)
v-list-item-group(v-model='selectedStrategyKey') v-list-item-group(v-model='selectedStrategyKey')
v-list-item( v-list-item(
v-for='(stg, idx) of strategies' v-for='(stg, idx) of filteredStrategies'
:key='stg.key' :key='stg.key'
:value='stg.key' :value='stg.key'
:color='stg.strategy.color' :color='stg.strategy.color'
@ -252,8 +252,8 @@ export default {
return { return {
error: false, error: false,
strategies: [], strategies: [],
selectedStrategyKey: 'local', selectedStrategyKey: 'unselected',
selectedStrategy: { key: 'local', strategy: { useForm: true } }, selectedStrategy: { key: 'unselected', strategy: { useForm: false } },
screen: 'login', screen: 'login',
username: '', username: '',
password: '', password: '',
@ -276,11 +276,21 @@ export default {
isSocialShown () { isSocialShown () {
return this.strategies.length > 1 return this.strategies.length > 1
}, },
logoUrl () { return siteConfig.logoUrl } logoUrl () { return siteConfig.logoUrl },
filteredStrategies () {
const qParams = new URLSearchParams(window.location.search)
if (this.hideLocal && !qParams.has('all')) {
return _.reject(this.strategies, ['key', 'local'])
} else {
return this.strategies
}
}
}, },
watch: { watch: {
strategies(newValue, oldValue) { filteredStrategies (newValue, oldValue) {
this.selectedStrategy = _.head(newValue) if (_.head(newValue).strategy.useForm) {
this.selectedStrategyKey = _.head(newValue).key
}
}, },
selectedStrategyKey (newValue, oldValue) { selectedStrategyKey (newValue, oldValue) {
this.selectedStrategy = _.find(this.strategies, ['key', newValue]) this.selectedStrategy = _.find(this.strategies, ['key', newValue])

View File

@ -55,6 +55,7 @@ defaults:
darkMode: false darkMode: false
auth: auth:
autoLogin: false autoLogin: false
enforce2FA: false
hideLocal: false hideLocal: false
loginBgUrl: '' loginBgUrl: ''
audience: 'urn:wiki.js' audience: 'urn:wiki.js'

View File

@ -22,6 +22,7 @@ module.exports = {
...WIKI.config.features, ...WIKI.config.features,
...WIKI.config.security, ...WIKI.config.security,
authAutoLogin: WIKI.config.auth.autoLogin, authAutoLogin: WIKI.config.auth.autoLogin,
authEnforce2FA: WIKI.config.auth.enforce2FA,
authHideLocal: WIKI.config.auth.hideLocal, authHideLocal: WIKI.config.auth.hideLocal,
authLoginBgUrl: WIKI.config.auth.loginBgUrl, authLoginBgUrl: WIKI.config.auth.loginBgUrl,
authJwtAudience: WIKI.config.auth.audience, authJwtAudience: WIKI.config.auth.audience,
@ -68,6 +69,7 @@ module.exports = {
WIKI.config.auth = { WIKI.config.auth = {
autoLogin: _.get(args, 'authAutoLogin', WIKI.config.auth.autoLogin), autoLogin: _.get(args, 'authAutoLogin', WIKI.config.auth.autoLogin),
enforce2FA: _.get(args, 'authEnforce2FA', WIKI.config.auth.enforce2FA),
hideLocal: _.get(args, 'authHideLocal', WIKI.config.auth.hideLocal), hideLocal: _.get(args, 'authHideLocal', WIKI.config.auth.hideLocal),
loginBgUrl: _.get(args, 'authLoginBgUrl', WIKI.config.auth.loginBgUrl), loginBgUrl: _.get(args, 'authLoginBgUrl', WIKI.config.auth.loginBgUrl),
audience: _.get(args, 'authJwtAudience', WIKI.config.auth.audience), audience: _.get(args, 'authJwtAudience', WIKI.config.auth.audience),

View File

@ -34,6 +34,7 @@ type SiteMutation {
contentLicense: String contentLicense: String
logoUrl: String logoUrl: String
authAutoLogin: Boolean authAutoLogin: Boolean
authEnforce2FA: Boolean
authHideLocal: Boolean authHideLocal: Boolean
authLoginBgUrl: String authLoginBgUrl: String
authJwtAudience: String authJwtAudience: String
@ -72,6 +73,7 @@ type SiteConfig {
contentLicense: String! contentLicense: String!
logoUrl: String! logoUrl: String!
authAutoLogin: Boolean authAutoLogin: Boolean
authEnforce2FA: Boolean
authHideLocal: Boolean authHideLocal: Boolean
authLoginBgUrl: String authLoginBgUrl: String
authJwtAudience: String authJwtAudience: String