Skip to content

Commit

Permalink
chore: update skip path to use prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
yashmehrotra committed Nov 11, 2024
1 parent c8e676a commit 612152b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion auth/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log/slog"
"slices"

Check failure on line 8 in auth/middleware.go

View workflow job for this annotation

GitHub Actions / lint

"slices" imported and not used (typecheck)

Check failure on line 8 in auth/middleware.go

View workflow job for this annotation

GitHub Actions / lint

"slices" imported and not used) (typecheck)

Check failure on line 8 in auth/middleware.go

View workflow job for this annotation

GitHub Actions / lint

"slices" imported and not used) (typecheck)

Check failure on line 8 in auth/middleware.go

View workflow job for this annotation

GitHub Actions / lint

"slices" imported and not used) (typecheck)
"strings"
"time"

"github.com/flanksource/commons/hash"
Expand Down Expand Up @@ -111,7 +112,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 {
Expand Down

0 comments on commit 612152b

Please sign in to comment.