pull/3786/merge
PaulD987 1 week ago committed by GitHub
commit 7290d7992d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -187,6 +187,15 @@
persistent-hint persistent-hint
:hint='$t(`admin:security.bypassLoginHint`)' :hint='$t(`admin:security.bypassLoginHint`)'
) )
v-switch(
inset
:label='$t(`admin:security.bypassUnauthorized`)'
color='primary'
v-model='config.authBypassUnauthorized'
prepend-icon='mdi-fast-forward'
persistent-hint
:hint='$t(`admin:security.bypassUnauthorizedHint`)'
)
v-switch( v-switch(
inset inset
:label='$t(`admin:security.hideLocalLogin`)' :label='$t(`admin:security.hideLocalLogin`)'
@ -272,6 +281,7 @@ export default {
securityCSP: false, securityCSP: false,
securityCSPDirectives: '', securityCSPDirectives: '',
authAutoLogin: false, authAutoLogin: false,
authBypassUnauthorized: false,
authHideLocal: false, authHideLocal: false,
authLoginBgUrl: '', authLoginBgUrl: '',
authJwtAudience: 'urn:wiki.js', authJwtAudience: 'urn:wiki.js',
@ -298,6 +308,7 @@ export default {
mutation: gql` mutation: gql`
mutation ( mutation (
$authAutoLogin: Boolean $authAutoLogin: Boolean
$authBypassUnauthorized: Boolean
$authEnforce2FA: Boolean $authEnforce2FA: Boolean
$authHideLocal: Boolean $authHideLocal: Boolean
$authLoginBgUrl: String $authLoginBgUrl: String
@ -321,6 +332,7 @@ export default {
site { site {
updateConfig( updateConfig(
authAutoLogin: $authAutoLogin, authAutoLogin: $authAutoLogin,
authBypassUnauthorized: $authBypassUnauthorized,
authEnforce2FA: $authEnforce2FA, authEnforce2FA: $authEnforce2FA,
authHideLocal: $authHideLocal, authHideLocal: $authHideLocal,
authLoginBgUrl: $authLoginBgUrl, authLoginBgUrl: $authLoginBgUrl,
@ -353,6 +365,7 @@ export default {
`, `,
variables: { variables: {
authAutoLogin: _.get(this.config, 'authAutoLogin', false), authAutoLogin: _.get(this.config, 'authAutoLogin', false),
authBypassUnauthorized: _.get(this.config, 'authBypassUnauthorized', false),
authEnforce2FA: _.get(this.config, 'authEnforce2FA', 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', ''),
@ -406,6 +419,7 @@ export default {
site { site {
config { config {
authAutoLogin authAutoLogin
authBypassUnauthorized
authEnforce2FA authEnforce2FA
authHideLocal authHideLocal
authLoginBgUrl authLoginBgUrl

@ -63,6 +63,7 @@ defaults:
tocPosition: 'left' tocPosition: 'left'
auth: auth:
autoLogin: false autoLogin: false
bypassUnauthorized: false
enforce2FA: false enforce2FA: false
hideLocal: false hideLocal: false
loginBgUrl: '' loginBgUrl: ''

@ -447,7 +447,11 @@ router.get('/*', async (req, res, next) => {
maxAge: 15 * 60 * 1000 maxAge: 15 * 60 * 1000
}) })
} }
if (pageArgs.path === 'home' && req.user.id === 2) {
// If the user is the guest user (id 2) and either trying to access the home page for the wiki
// or the wiki is configured to not show unauthorized for the guest user,
// redirect to the login page for the wiki.
if ((pageArgs.path === 'home' || WIKI.config.auth.bypassUnauthorized) && req.user.id === 2) {
return res.redirect('/login') return res.redirect('/login')
} }
_.set(res.locals, 'pageMeta.title', 'Unauthorized') _.set(res.locals, 'pageMeta.title', 'Unauthorized')

@ -25,6 +25,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,
authBypassUnauthorized: WIKI.config.auth.bypassUnauthorized,
authEnforce2FA: WIKI.config.auth.enforce2FA, 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,
@ -82,6 +83,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),
bypassUnauthorized: _.get(args, 'authBypassUnauthorized', WIKI.config.auth.bypassUnauthorized),
enforce2FA: _.get(args, 'authEnforce2FA', WIKI.config.auth.enforce2FA), 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),

@ -36,6 +36,7 @@ type SiteMutation {
logoUrl: String logoUrl: String
pageExtensions: String pageExtensions: String
authAutoLogin: Boolean authAutoLogin: Boolean
authBypassUnauthorized: Boolean
authEnforce2FA: Boolean authEnforce2FA: Boolean
authHideLocal: Boolean authHideLocal: Boolean
authLoginBgUrl: String authLoginBgUrl: String
@ -86,6 +87,7 @@ type SiteConfig {
logoUrl: String logoUrl: String
pageExtensions: String pageExtensions: String
authAutoLogin: Boolean authAutoLogin: Boolean
authBypassUnauthorized: Boolean
authEnforce2FA: Boolean authEnforce2FA: Boolean
authHideLocal: Boolean authHideLocal: Boolean
authLoginBgUrl: String authLoginBgUrl: String

Loading…
Cancel
Save