fix: tinyauth should allow the user to access a resource if a whitelist is not setup

This commit is contained in:
Stavros
2025-04-08 16:24:25 +03:00
parent c664be5cc5
commit 38c5cd7b32
3 changed files with 6 additions and 2 deletions

View File

@@ -40,7 +40,7 @@
"totpSuccessSubtitle": "Redirecting to your app",
"totpTitle": "Enter your TOTP code",
"unauthorizedTitle": "Unauthorized",
"unauthorizedResourceSubtitle": "The user with username {{username}} is not authorized to access the resource <Code>{{resource}}</Code>.",
"unaothorizedLoginSubtitle": "The user with username {{username}} is not authorized to login.",
"unauthorizedResourceSubtitle": "The user with username <Code>{{username}}<Code/> is not authorized to access the resource <Code>{{resource}}</Code>.",
"unaothorizedLoginSubtitle": "The user with username <Code>{{username}}<Code/> is not authorized to login.",
"unauthorizedButton": "Try again"
}

View File

@@ -37,6 +37,7 @@ export const UnauthorizedPage = () => {
<Trans
i18nKey="unauthorizedLoginSubtitle"
t={t}
components={{ Code: <Code /> }}
values={{ username }}
/>
</Text>

View File

@@ -295,6 +295,9 @@ func (auth *Auth) ResourceAllowed(c *gin.Context, context types.UserContext) (bo
// Check if user is allowed
if len(labels.Users) != 0 {
log.Debug().Msg("Checking users")
if len(labels.Users) == 0 {
return true, nil
}
if slices.Contains(labels.Users, context.Username) {
return true, nil
}