Skip to content

Commit

Permalink
Improve error message for checking claims.Audience
Browse files Browse the repository at this point in the history
  • Loading branch information
paskal committed Dec 10, 2024
1 parent f473105 commit 161257b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/app/cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1215,6 +1215,7 @@ func (s *ServerCommand) getAuthenticator(ds *service.DataStore, avas avatar.Stor
if c.User == nil {
return c
}
// Audience is a slice but we set it to a single element, and situation when there is no audience or there are more than one is unexpected
if len(c.Audience) != 1 {
return c
}
Expand Down
3 changes: 2 additions & 1 deletion backend/app/rest/api/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ func (a *admin) deleteMeRequestCtrl(w http.ResponseWriter, r *http.Request) {
return
}

// Audience is a slice but we set it to a single element, and situation when there is no audience or there are more than one is unexpected
if len(claims.Audience) != 1 {
rest.SendErrorJSON(w, r, http.StatusBadRequest, fmt.Errorf("bad request"), "can't process token, aud is not a single element", rest.ErrActionRejected)
rest.SendErrorJSON(w, r, http.StatusBadRequest, fmt.Errorf("bad request"), "can't process token, claims.Audience expected to be a single element but it's not", rest.ErrActionRejected)
return
}

Expand Down

0 comments on commit 161257b

Please sign in to comment.