Skip to content

Commit

Permalink
return missing error
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadelrouby committed Sep 6, 2024
1 parent 805ea3e commit 3862a07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ func (a *Authorizer) Authorize(_ http.ResponseWriter, r *http.Request, authOptio
} else {
// Use previously decoded values
missing, ok = r.Context().Value("authTokenMissing").(bool)
if !ok || missing {
return api.AuthorizationResult{Error: stacktrace.NewErrorWithCode(dsserr.Unauthenticated, "Missing access token")}
if !ok {
missing = true
}

validated, ok = r.Context().Value("authValidated").(bool)
Expand All @@ -217,6 +217,10 @@ func (a *Authorizer) Authorize(_ http.ResponseWriter, r *http.Request, authOptio
}
}

if missing {
return api.AuthorizationResult{Error: stacktrace.NewErrorWithCode(dsserr.Unauthenticated, "Missing access token")}
}

if !validated {
return api.AuthorizationResult{Error: stacktrace.PropagateWithCode(err, dsserr.Unauthenticated, "Access token validation failed")}
}
Expand Down

0 comments on commit 3862a07

Please sign in to comment.