From 05dabd2a7eb0391c4d3b1358950dd66f62b00ab7 Mon Sep 17 00:00:00 2001 From: Yash Mehrotra Date: Mon, 11 Nov 2024 13:19:59 +0530 Subject: [PATCH] chore: update skip path to use prefix --- auth/middleware.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/auth/middleware.go b/auth/middleware.go index ca1a0480..ce72bf6e 100644 --- a/auth/middleware.go +++ b/auth/middleware.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "log/slog" - "slices" + "strings" "time" "github.com/flanksource/commons/hash" @@ -111,7 +111,12 @@ func Middleware(ctx context.Context, e *echo.Echo) error { // TODO: Use regex supported path matching func canSkipAuth(c echo.Context) bool { - return slices.Contains(skipAuthPaths, c.Path()) + for _, p := range skipAuthPaths { + if strings.HasPrefix(c.Path(), p) { + return true + } + } + return false } func mapIDsToRoles(ctx context.Context, session *client.Session, person models.Person) error {