feat: login bg + bypass + hide local option
This commit is contained in:
parent
5282a82afe
commit
b475795595
@ -163,12 +163,21 @@
|
|||||||
v-switch(
|
v-switch(
|
||||||
inset
|
inset
|
||||||
:label='$t(`admin:security.bypassLogin`)'
|
:label='$t(`admin:security.bypassLogin`)'
|
||||||
color='red darken-2'
|
color='primary'
|
||||||
v-model='config.authAutoLogin'
|
v-model='config.authAutoLogin'
|
||||||
prepend-icon='mdi-fast-forward'
|
prepend-icon='mdi-fast-forward'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
:hint='$t(`admin:security.bypassLoginHint`)'
|
:hint='$t(`admin:security.bypassLoginHint`)'
|
||||||
)
|
)
|
||||||
|
v-switch(
|
||||||
|
inset
|
||||||
|
:label='$t(`admin:security.hideLocalLogin`)'
|
||||||
|
color='primary'
|
||||||
|
v-model='config.authHideLocal'
|
||||||
|
prepend-icon='mdi-eye-off-outline'
|
||||||
|
persistent-hint
|
||||||
|
:hint='$t(`admin:security.hideLocalLoginHint`)'
|
||||||
|
)
|
||||||
v-divider.mt-3
|
v-divider.mt-3
|
||||||
.overline.grey--text.pa-4 {{$t('admin:security.jwt')}}
|
.overline.grey--text.pa-4 {{$t('admin:security.jwt')}}
|
||||||
.px-4.pb-3
|
.px-4.pb-3
|
||||||
@ -231,6 +240,7 @@ export default {
|
|||||||
securityCSP: false,
|
securityCSP: false,
|
||||||
securityCSPDirectives: '',
|
securityCSPDirectives: '',
|
||||||
authAutoLogin: false,
|
authAutoLogin: false,
|
||||||
|
authHideLocal: false,
|
||||||
authLoginBgUrl: '',
|
authLoginBgUrl: '',
|
||||||
authJwtAudience: 'urn:wiki.js',
|
authJwtAudience: 'urn:wiki.js',
|
||||||
authJwtExpiration: '30m',
|
authJwtExpiration: '30m',
|
||||||
@ -256,6 +266,7 @@ export default {
|
|||||||
mutation: gql`
|
mutation: gql`
|
||||||
mutation (
|
mutation (
|
||||||
$authAutoLogin: Boolean
|
$authAutoLogin: Boolean
|
||||||
|
$authHideLocal: Boolean
|
||||||
$authLoginBgUrl: String
|
$authLoginBgUrl: String
|
||||||
$authJwtAudience: String
|
$authJwtAudience: String
|
||||||
$authJwtExpiration: String
|
$authJwtExpiration: String
|
||||||
@ -275,6 +286,7 @@ export default {
|
|||||||
site {
|
site {
|
||||||
updateConfig(
|
updateConfig(
|
||||||
authAutoLogin: $authAutoLogin,
|
authAutoLogin: $authAutoLogin,
|
||||||
|
authHideLocal: $authHideLocal,
|
||||||
authLoginBgUrl: $authLoginBgUrl,
|
authLoginBgUrl: $authLoginBgUrl,
|
||||||
authJwtAudience: $authJwtAudience,
|
authJwtAudience: $authJwtAudience,
|
||||||
authJwtExpiration: $authJwtExpiration,
|
authJwtExpiration: $authJwtExpiration,
|
||||||
@ -303,6 +315,7 @@ export default {
|
|||||||
`,
|
`,
|
||||||
variables: {
|
variables: {
|
||||||
authAutoLogin: _.get(this.config, 'authAutoLogin', false),
|
authAutoLogin: _.get(this.config, 'authAutoLogin', 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', ''),
|
||||||
authJwtExpiration: _.get(this.config, 'authJwtExpiration', ''),
|
authJwtExpiration: _.get(this.config, 'authJwtExpiration', ''),
|
||||||
@ -352,6 +365,7 @@ export default {
|
|||||||
site {
|
site {
|
||||||
config {
|
config {
|
||||||
authAutoLogin
|
authAutoLogin
|
||||||
|
authHideLocal
|
||||||
authLoginBgUrl
|
authLoginBgUrl
|
||||||
authJwtAudience
|
authJwtAudience
|
||||||
authJwtExpiration
|
authJwtExpiration
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template lang="pug">
|
<template lang="pug">
|
||||||
v-app
|
v-app
|
||||||
.login
|
.login(:style='`background-image: url(` + bgUrl + `);`')
|
||||||
.login-sd
|
.login-sd
|
||||||
.d-flex
|
.d-flex
|
||||||
.login-logo
|
.login-logo
|
||||||
@ -238,6 +238,16 @@ import { sync } from 'vuex-pathify'
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
i18nOptions: { namespaces: 'auth' },
|
i18nOptions: { namespaces: 'auth' },
|
||||||
|
props: {
|
||||||
|
bgUrl: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
hideLocal: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
error: false,
|
error: false,
|
||||||
@ -535,7 +545,8 @@ export default {
|
|||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.login {
|
.login {
|
||||||
background-image: url('/_assets/img/splash/1.jpg');
|
// background-image: url('/_assets/img/splash/1.jpg');
|
||||||
|
background-color: mc('grey', '900');
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
background-position: center center;
|
background-position: center center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
@ -55,6 +55,7 @@ defaults:
|
|||||||
darkMode: false
|
darkMode: false
|
||||||
auth:
|
auth:
|
||||||
autoLogin: false
|
autoLogin: false
|
||||||
|
hideLocal: false
|
||||||
loginBgUrl: ''
|
loginBgUrl: ''
|
||||||
audience: 'urn:wiki.js'
|
audience: 'urn:wiki.js'
|
||||||
tokenExpiration: '30m'
|
tokenExpiration: '30m'
|
||||||
|
@ -33,7 +33,17 @@ router.get('/login', async (req, res, next) => {
|
|||||||
socialStrategies
|
socialStrategies
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
res.render('login')
|
// -> Bypass Login
|
||||||
|
if (WIKI.config.auth.autoLogin && !req.query.all) {
|
||||||
|
const stg = await WIKI.models.authentication.query().orderBy('order').first()
|
||||||
|
const stgInfo = _.find(WIKI.data.authentication, ['key', stg.strategyKey])
|
||||||
|
if (!stgInfo.useForm) {
|
||||||
|
return res.redirect(`/login/${stg.key}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// -> Show Login
|
||||||
|
const bgUrl = !_.isEmpty(WIKI.config.auth.loginBgUrl) ? WIKI.config.auth.loginBgUrl : '/_assets/img/splash/1.jpg'
|
||||||
|
res.render('login', { bgUrl, hideLocal: WIKI.config.auth.hideLocal })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -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,
|
||||||
|
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,
|
||||||
authJwtExpiration: WIKI.config.auth.tokenExpiration,
|
authJwtExpiration: WIKI.config.auth.tokenExpiration,
|
||||||
@ -67,6 +68,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),
|
||||||
|
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),
|
||||||
tokenExpiration: _.get(args, 'authJwtExpiration', WIKI.config.auth.tokenExpiration),
|
tokenExpiration: _.get(args, 'authJwtExpiration', WIKI.config.auth.tokenExpiration),
|
||||||
|
@ -34,6 +34,7 @@ type SiteMutation {
|
|||||||
contentLicense: String
|
contentLicense: String
|
||||||
logoUrl: String
|
logoUrl: String
|
||||||
authAutoLogin: Boolean
|
authAutoLogin: Boolean
|
||||||
|
authHideLocal: Boolean
|
||||||
authLoginBgUrl: String
|
authLoginBgUrl: String
|
||||||
authJwtAudience: String
|
authJwtAudience: String
|
||||||
authJwtExpiration: String
|
authJwtExpiration: String
|
||||||
@ -71,6 +72,7 @@ type SiteConfig {
|
|||||||
contentLicense: String!
|
contentLicense: String!
|
||||||
logoUrl: String!
|
logoUrl: String!
|
||||||
authAutoLogin: Boolean
|
authAutoLogin: Boolean
|
||||||
|
authHideLocal: Boolean
|
||||||
authLoginBgUrl: String
|
authLoginBgUrl: String
|
||||||
authJwtAudience: String
|
authJwtAudience: String
|
||||||
authJwtExpiration: String
|
authJwtExpiration: String
|
||||||
|
@ -36,11 +36,11 @@ module.exports = class Authentication extends Model {
|
|||||||
|
|
||||||
static async getStrategies() {
|
static async getStrategies() {
|
||||||
const strategies = await WIKI.models.authentication.query().orderBy('order')
|
const strategies = await WIKI.models.authentication.query().orderBy('order')
|
||||||
return _.sortBy(strategies.map(str => ({
|
return strategies.map(str => ({
|
||||||
...str,
|
...str,
|
||||||
domainWhitelist: _.get(str.domainWhitelist, 'v', []),
|
domainWhitelist: _.get(str.domainWhitelist, 'v', []),
|
||||||
autoEnrollGroups: _.get(str.autoEnrollGroups, 'v', [])
|
autoEnrollGroups: _.get(str.autoEnrollGroups, 'v', [])
|
||||||
})), ['key'])
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
static async getStrategiesForLegacyClient() {
|
static async getStrategiesForLegacyClient() {
|
||||||
|
@ -2,4 +2,7 @@ extends master.pug
|
|||||||
|
|
||||||
block body
|
block body
|
||||||
#root.is-fullscreen
|
#root.is-fullscreen
|
||||||
login
|
login(
|
||||||
|
bg-url=bgUrl
|
||||||
|
hide-local=hideLocal
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user