Skip to content

Commit f2b4507

Browse files
committed
fix(m2m): reject empty expected_aud on trusted issuer update
UpdateTrustedIssuer let a caller blank expected_aud even though AddTrustedIssuer already rejects it empty. expected_aud backs the audience-binding invariant the token endpoint will enforce later, so the update path shouldn't be the hole that lets it go empty.
1 parent 598e935 commit f2b4507

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

internal/integration_tests/trusted_issuer_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ func TestTrustedIssuerAdmin(t *testing.T) {
9494
assert.Equal(t, saID, updated.ServiceAccountID)
9595
})
9696

97+
t.Run("update rejects blanking expected_aud", func(t *testing.T) {
98+
saID := createSA(t)
99+
created, err := ts.GraphQLProvider.AddTrustedIssuer(ctx, newIssuerReq(saID))
100+
require.NoError(t, err)
101+
102+
_, err = ts.GraphQLProvider.UpdateTrustedIssuer(ctx, &model.UpdateTrustedIssuerRequest{
103+
ID: created.ID,
104+
ExpectedAud: refs.NewStringRef(" "),
105+
})
106+
require.Error(t, err)
107+
})
108+
97109
t.Run("list filters by service_account_id", func(t *testing.T) {
98110
saID := createSA(t)
99111
_, err := ts.GraphQLProvider.AddTrustedIssuer(ctx, newIssuerReq(saID))

internal/service/admin_trusted_issuers.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ func (p *provider) UpdateTrustedIssuer(ctx context.Context, meta RequestMetadata
110110
issuer.JWKSUrl = params.JwksURL
111111
}
112112
if params.ExpectedAud != nil {
113+
if strings.TrimSpace(*params.ExpectedAud) == "" {
114+
log.Debug().Msg("expected_aud cannot be empty")
115+
return nil, nil, fmt.Errorf("expected_aud cannot be empty")
116+
}
113117
issuer.ExpectedAud = *params.ExpectedAud
114118
}
115119
if params.IsActive != nil {

0 commit comments

Comments
 (0)