Repository navigation
Add JWT-SVID audience policy configuration with JTI claim support - #6514
Conversation
6e39f46 to
f45e5a4
Compare
1d8392e to
f45e5a4
Compare
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514
|
Thanks @srikalyan for opening this! We discussed this today and we think it might be good to start with something simple at first by having just the entry level policy (maybe called something like We also think we should combine this flag with the changes in #6360. This avoid the need to have these seldomly used flags as individual columns in the database. I don't know what's the current state of the work from @ValFadeev, but maybe you can continue from where he left off? |
@ValFadeev let me know if you are ok in me making the necessary change? |
|
@srikalyan yes, I am happy for you to do so and to discuss if necessary. I was still aiming to allocate the time to finish that work, but would not want to hold the progress |
|
Hi, @srikalyan We'll be merging github.com//pull/6360 in SPIRE 1.15.0, which will be the next release after 1.14.3. If you want, you can rebase this on top of that PR or wait until it gets merged into main. |
|
Thank you @sorindumitru Will do it soon. |
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514
f45e5a4 to
101e2c9
Compare
|
Rebased the branch and will wait for your merge to finish. |
101e2c9 to
3b3ed71
Compare
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514
3b3ed71 to
b195d56
Compare
|
@sorindumitru now that the other feature is merged, can we get this PR rolling? |
|
Yes, I hope I can have a run over this over the weekend and provide some feedback. |
Had a look through the code for a bit, I'll look some more, but I notice we still have both the flag + the audience map. I don't think it's that likely to configure things per audience so in the interest of keeping the configuration simple we should start with a simple flag, maybe just You'll also have to add the flag to the new AdditionalAttributes structure instead of directly to the entry (this will also fix some issues around parsing the field in this PR, i think listing entries doesn't currently parse the fields). |
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514
|
Hi @srikalyan, just checking in to see if you're still planning on updating this to use the new field added in the SDK. |
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514
sorindumitru
left a comment
There was a problem hiding this comment.
LGTM, thanks @srikalyan! Would you mind fixing up the DCO?
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514 Signed-off-by: Srikalyan Swayampakula <[email protected]>
9224847 to
e57ff00
Compare
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514 Signed-off-by: Srikalyan Swayampakula <[email protected]>
e57ff00 to
2b99b45
Compare
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514 Signed-off-by: Srikalyan Swayampakula <[email protected]>
2b99b45 to
201051c
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR introduces a per-registration-entry option to include a unique jti claim in issued JWT-SVIDs and ensures those JWT-SVIDs are not served from (or written to) the agent-side JWT-SVID cache.
Changes:
- Added
jwt_svid_include_jtitoRegistrationEntry.AdditionalAttributesand wired it through server signing/minting paths. - Implemented agent behavior to bypass JWT-SVID cache when
jwt_svid_include_jtiis enabled. - Updated CLI create/update flows and expanded tests across server/agent to validate
jtipresence and cache bypass behavior.
Reviewed changes
Copilot reviewed 20 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| proto/spire/common/common.proto | Adds jwt_svid_include_jti flag to entry AdditionalAttributes and documents expected behavior. |
| pkg/server/credtemplate/builder.go | Adds IncludeJTI param and emits jti claim when requested. |
| pkg/server/credtemplate/builder_test.go | Adds test coverage for jti generation and verifies it’s absent by default. |
| pkg/server/ca/ca.go | Threads IncludeJTI through CA signing parameters. |
| pkg/server/api/svid/v1/service.go | Plumbs per-entry jwt_svid_include_jti into JWT-SVID minting path. |
| pkg/server/api/svid/v1/service_test.go | Adds cases asserting jti presence/absence based on entry attributes. |
| pkg/server/api/entry.go | Maps JwtSvidIncludeJti between datastore/common and API types. |
| pkg/server/api/entry_test.go | Updates clone test to include new AdditionalAttributes field. |
| pkg/server/api/entry/v1/service.go | Extends registration entry mask to include AdditionalAttributes. |
| pkg/server/api/entry/v1/service_test.go | Adds batch update coverage for AdditionalAttributes updates/no-ops. |
| pkg/agent/manager/manager.go | Bypasses JWT-SVID cache when jwt_svid_include_jti is set. |
| pkg/agent/manager/manager_test.go | Adds test asserting cache bypass behavior when jwt_svid_include_jti is enabled. |
| cmd/spire-server/cli/entry/create.go | Adds -jwtSVIDIncludeJTI and emits it into AdditionalAttributes. |
| cmd/spire-server/cli/entry/create_test.go | Updates expected JSON to include jwt_svid_include_jti. |
| cmd/spire-server/cli/entry/update.go | Adds -jwtSVIDIncludeJTI and merges AdditionalAttributes to avoid clobbering siblings. |
| cmd/spire-server/cli/entry/update_test.go | Adds tests ensuring AdditionalAttributes merge/preservation behavior. |
| cmd/spire-server/cli/entry/util.go | Prints JwtSvidIncludeJti when enabled. |
| cmd/spire-server/cli/entry/util_posix_test.go | Updates usage/help text expectations to include new flag. |
| cmd/spire-server/cli/entry/util_windows_test.go | Updates usage/help text expectations to include new flag. |
| go.mod | Bumps github.com/spiffe/spire-api-sdk to a newer pseudo-version. |
| go.sum | Updates checksums for the bumped spire-api-sdk version. |
Files not reviewed (1)
- proto/spire/common/common.pb.go: Language not supported
…iffe#6043) Introduces per-audience JWT-SVID policy configuration to control JTI (JWT ID) claim inclusion and agent-side caching behavior. New JWTSVIDAudiencePolicy enum with three modes: - DEFAULT (0): No JTI, caching enabled (backwards compatible) - AUDITABLE (1): JTI included, caching enabled - UNIQUE (2): JTI included, caching disabled Features: - Per-entry default policy via jwt_svid_default_audience_policy - Per-audience overrides via jwt_svid_audience_policies map - "Most restrictive wins" for multi-audience tokens - Database schema v24 with entry_audience_policies table - Agent cache bypass for UNIQUE policy Note: API SDK and CLI integration will follow in a separate commit after spire-api-sdk is updated. Signed-off-by: Srikalyan Swayampakula <[email protected]>
This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514 Signed-off-by: Srikalyan Swayampakula <[email protected]>
Replaces local-path replace directive with the merged upstream SDK pseudo-version so CI can resolve the new jwt_svid_include_jti field from the public module proxy. Signed-off-by: Srikalyan Swayampakula <[email protected]>
The updateEntry mask translation in the entry v1 service was missing the AdditionalAttributes field, so masked updates targeting that field were silently dropped before reaching the datastore. Map the input mask bit through and add coverage for both the honored and ignored cases. Signed-off-by: Srikalyan Swayampakula <[email protected]>
The protobuf AdditionalAttributes message has no per-field mask, so a CLI update that set only one of -disableX509SVIDPrefetch or -jwtSVIDIncludeJTI would clobber the unset sibling bit with its zero value. Track each flag's set state independently and, when exactly one is supplied (and -data is not in use), fetch the existing entry to merge the unspecified bit before BatchUpdateEntry. GetEntry failures short-circuit before any update is attempted. Signed-off-by: Srikalyan Swayampakula <[email protected]>
- pkg/server/api/svid/v1/service.go: add explicit nil check for GetAdditionalAttributes() before reading JwtSvidIncludeJti; add test cases covering nil attrs, JTI false, and JTI true paths. - pkg/server/credtemplate/builder.go: return error from jti UUID generation instead of panicking via uuid.Must; encode the 16 random bytes as base64url for a more compact claim value. - cmd/spire-server/cli/entry/update.go: gate the existing-entry fetch on a single additionalAttributesSet flag, then merge each AdditionalAttributes field individually so unspecified flags preserve the existing value. - pkg/agent/manager/manager_test.go: add TestFetchJWTSVIDWithJTIBypassesCache proving JwtSvidIncludeJti bypasses both the cache read and write. - pkg/server/api/entry_test.go: only add JwtSvidIncludeJti: true in TestReadOnlyEntryClone; revert unintended prefetch change. Signed-off-by: Srikalyan Swayampakula <[email protected]>
Switch mergeAdditionalAttributes to proto.Clone the existing message and override only fields explicitly set on the command line. This preserves unknown fields and any future AdditionalAttributes the binary does not know about, so the merge does not need editing when new fields are added. Also harden the agent's bypassCache read with a nil-safe chained getter. Signed-off-by: Srikalyan Swayampakula <[email protected]>
792ca83 to
c14b0d8
Compare
|
@sorindumitru can you give one more ship it, had to address copilot review |
…iffe#6514) * Add JWT-SVID audience policy configuration with JTI claim support (spiffe#6043) Introduces per-audience JWT-SVID policy configuration to control JTI (JWT ID) claim inclusion and agent-side caching behavior. New JWTSVIDAudiencePolicy enum with three modes: - DEFAULT (0): No JTI, caching enabled (backwards compatible) - AUDITABLE (1): JTI included, caching enabled - UNIQUE (2): JTI included, caching disabled Features: - Per-entry default policy via jwt_svid_default_audience_policy - Per-audience overrides via jwt_svid_audience_policies map - "Most restrictive wins" for multi-audience tokens - Database schema v24 with entry_audience_policies table - Agent cache bypass for UNIQUE policy Note: API SDK and CLI integration will follow in a separate commit after spire-api-sdk is updated. Signed-off-by: Srikalyan Swayampakula <[email protected]> * Add CLI and entry conversion support for JWT-SVID audience policies This commit adds support for the new JWT-SVID audience policy configuration in the SPIRE server CLI and entry conversion logic: CLI changes: - Add -jwtSVIDDefaultAudiencePolicy flag for default audience policy - Add -jwtSVIDAudiencePolicy flag for per-audience policy configuration - Update entry create, update, and show commands to handle new fields - Add AudiencePolicyFlag custom type for parsing audience:policy pairs Entry conversion: - Add JwtSvidDefaultAudiencePolicy and JwtSvidAudiencePolicies to EntryToProto and ProtoToEntry conversion functions - Add audiencePolicyToInternal helper for enum conversion Policy options: default, auditable, unique - default: No JTI claim, caching enabled (current behavior) - auditable: JTI claim included, caching enabled - unique: JTI claim included, caching disabled (unique tokens) Part of spiffe#6043 NOTE: Only merge after these dependent PRs are merged: - spire-api-sdk: spiffe/spire-api-sdk#84 - spire: spiffe#6514 Signed-off-by: Srikalyan Swayampakula <[email protected]> * Bump spire-api-sdk to merged JTI commit (PR spiffe#95) Replaces local-path replace directive with the merged upstream SDK pseudo-version so CI can resolve the new jwt_svid_include_jti field from the public module proxy. Signed-off-by: Srikalyan Swayampakula <[email protected]> * Persist AdditionalAttributes through entry update mask The updateEntry mask translation in the entry v1 service was missing the AdditionalAttributes field, so masked updates targeting that field were silently dropped before reaching the datastore. Map the input mask bit through and add coverage for both the honored and ignored cases. Signed-off-by: Srikalyan Swayampakula <[email protected]> * Preserve sibling AdditionalAttributes on partial CLI entry update The protobuf AdditionalAttributes message has no per-field mask, so a CLI update that set only one of -disableX509SVIDPrefetch or -jwtSVIDIncludeJTI would clobber the unset sibling bit with its zero value. Track each flag's set state independently and, when exactly one is supplied (and -data is not in use), fetch the existing entry to merge the unspecified bit before BatchUpdateEntry. GetEntry failures short-circuit before any update is attempted. Signed-off-by: Srikalyan Swayampakula <[email protected]> * Address review feedback for JWT-SVID JTI claim - pkg/server/api/svid/v1/service.go: add explicit nil check for GetAdditionalAttributes() before reading JwtSvidIncludeJti; add test cases covering nil attrs, JTI false, and JTI true paths. - pkg/server/credtemplate/builder.go: return error from jti UUID generation instead of panicking via uuid.Must; encode the 16 random bytes as base64url for a more compact claim value. - cmd/spire-server/cli/entry/update.go: gate the existing-entry fetch on a single additionalAttributesSet flag, then merge each AdditionalAttributes field individually so unspecified flags preserve the existing value. - pkg/agent/manager/manager_test.go: add TestFetchJWTSVIDWithJTIBypassesCache proving JwtSvidIncludeJti bypasses both the cache read and write. - pkg/server/api/entry_test.go: only add JwtSvidIncludeJti: true in TestReadOnlyEntryClone; revert unintended prefetch change. Signed-off-by: Srikalyan Swayampakula <[email protected]> * Clone existing AdditionalAttributes on partial CLI entry update Switch mergeAdditionalAttributes to proto.Clone the existing message and override only fields explicitly set on the command line. This preserves unknown fields and any future AdditionalAttributes the binary does not know about, so the merge does not need editing when new fields are added. Also harden the agent's bypassCache read with a nil-safe chained getter. Signed-off-by: Srikalyan Swayampakula <[email protected]> --------- Signed-off-by: Srikalyan Swayampakula <[email protected]>
Summary
Implements issue #6043 - JWT JTI Attribute support with per-audience policy configuration.
This PR introduces a flexible JWT-SVID policy system that allows operators to control:
New
JWTSVIDAudiencePolicyenum with three modes:Configuration options:
jwt_svid_default_audience_policy: Default policy for audiences not explicitly configuredjwt_svid_audience_policies: Per-audience policy overrides (map of audience → policy)Key behaviors:
entry_audience_policiestable for per-audience configurationWhat's included in this PR:
What's NOT included (requires spire-api-sdk update):
These will follow in a separate PR after the spire-api-sdk is updated with the new types.
Test plan
Fixes #6043