Skip to content

Commit 57eddcb

Browse files
authored
feat: ignore aud claim from admin jwt (service_role never had one) (#2070)
There's a problem with new Secret API keys which mint a JWT where the `aud` claim is the requested resource. This is confusing list admin users in returning no users (since there's no such audience). `service_role` never had an `aud` claim in it, so this is the proper place to fix this.
1 parent b89bc32 commit 57eddcb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

internal/api/helpers.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ func (a *API) requestAud(ctx context.Context, r *http.Request) string {
4040
// Then check the token
4141
claims := getClaims(ctx)
4242

43-
if claims != nil {
43+
// ignore the JWT's aud claim if the role is admin
44+
// this is because anon, service_role never had an aud claim to begin with
45+
if claims != nil && !isStringInSlice(claims.Role, config.JWT.AdminRoles) {
4446
aud, _ := claims.GetAudience()
4547
if len(aud) != 0 && aud[0] != "" {
4648
return aud[0]

0 commit comments

Comments
 (0)