From 38c5cd7b32a23a30dee6aeb01fbfa2de31da1f0a Mon Sep 17 00:00:00 2001 From: Stavros Date: Tue, 8 Apr 2025 16:24:25 +0300 Subject: [PATCH] fix: tinyauth should allow the user to access a resource if a whitelist is not setup --- frontend/src/lib/i18n/locales/en.json | 4 ++-- frontend/src/pages/unauthorized-page.tsx | 1 + internal/auth/auth.go | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/i18n/locales/en.json b/frontend/src/lib/i18n/locales/en.json index 8a96a7cf..2d2ca038 100644 --- a/frontend/src/lib/i18n/locales/en.json +++ b/frontend/src/lib/i18n/locales/en.json @@ -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 {{resource}}.", - "unaothorizedLoginSubtitle": "The user with username {{username}} is not authorized to login.", + "unauthorizedResourceSubtitle": "The user with username {{username}} is not authorized to access the resource {{resource}}.", + "unaothorizedLoginSubtitle": "The user with username {{username}} is not authorized to login.", "unauthorizedButton": "Try again" } \ No newline at end of file diff --git a/frontend/src/pages/unauthorized-page.tsx b/frontend/src/pages/unauthorized-page.tsx index 4e0ddde2..fe6f693d 100644 --- a/frontend/src/pages/unauthorized-page.tsx +++ b/frontend/src/pages/unauthorized-page.tsx @@ -37,6 +37,7 @@ export const UnauthorizedPage = () => { }} values={{ username }} /> diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 5857c780..6c1e629b 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -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 }