Skip to content

Commit

Permalink
use Slices.contains
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard87 committed Apr 8, 2024
1 parent 2fedae9 commit 9899311
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ func AuthHandler(subjects []string, verifier Verifier) http.Handler {
}

subject := token.Subject
subjectIndex := slices.Index(subjects, subject)
if subjectIndex == -1 {
found := slices.Contains(subjects, subject)
if !found {
w.WriteHeader(http.StatusForbidden)
_, _ = w.Write([]byte("Forbidden"))
log.Info().Err(err).Dur("latency", time.Since(t)).Int("status", http.StatusForbidden).Str("sub", subject).Msg("Forbidden")
Expand Down

0 comments on commit 9899311

Please sign in to comment.