Skip to content

feat: add presence: IGNORED and failedStatusMetadataKey to JWTRule - #3801

Open
sayap wants to merge 1 commit into
istio:masterfrom
sayap:jwt-authn-presence-ignored
Open

sayap wants to merge 1 commit into
istio:masterfrom
sayap:jwt-authn-presence-ignored

Conversation

@sayap

@sayap sayap commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

presence: IGNORED makes the requirement always satisfied. In this mode, requests with a missing token and requests with an invalid token are both allowed.

failedStatusMetadataKey, if set, adds verification failure to the dynamic metadata under this key, such that failures are always observable regardless of the presence value.

@sayap
sayap requested a review from a team as a code owner October 9, 2026 02:57
@istio-testing istio-testing added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test labels Oct 9, 2026
@istio-testing

Copy link
Copy Markdown
Collaborator

Hi @sayap. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

1 similar comment
@istio-testing

Copy link
Copy Markdown
Collaborator

Hi @sayap. Thanks for your PR.

I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@sayap

sayap commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

This builds on top of #3737, mapping presence: IGNORED to allow_missing_or_failed in Envoy, to support the 1st bullet point of istio/istio#43982, while making it observable.

In Consul, this is even hardcoded to be allow_missing_or_failed.

@keithmattix

Copy link
Copy Markdown
Contributor

/ok-to-test

@istio-testing istio-testing added ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. and removed needs-ok-to-test labels Oct 19, 2026
@keithmattix

Copy link
Copy Markdown
Contributor

Can you provide some more context on the exact-use case here and what this API will solve?

// If set to true, a verification failure is written to the filter's dynamic metadata
// under the fixed key `istio_jwt_verification_failure`. The failure is then observable
// even when the request is not rejected, such as when `presence` is `IGNORED`.
bool failed_status_in_metadata = 16;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels like something that should just be not a flag and used if IGNORED is used

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I was undecided about this, and then I thought it might be useful to also enable this flag with OPTIONAL / REQUIRED as well.

In our case, when we transition a provider from IGNORED (dry-run) to OPTIONAL (enforce), keeping the same level of observability is desirable. So we just leave this flag enabled all the time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this from bool to string. Previously, I used bool to be consistent with the hardcoded EnvoyJwtFilterPayload = "payload". However, payload is more for internal usage, and there can only be one anyway. Meanwhile, this failed status is more external facing, to be used in conjunction with Telemetry CR, Lua filter, etc. Furthermore, when there are multiple providers, Envoy can add multiple verification failures to dynamic metadata. So I think a configurable string field is a better fit here.

@sayap

sayap commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

Can you provide some more context on the exact-use case here and what this API will solve?

We want to handle the first scenario described in istio/istio#43982, i.e. having a dry-run period where a mistake in mesh config or a misbehaving client does not result in 401.

REQUIRED = 1;

// The JWT requirement is always satisfied. A request with a missing or
// failed token is not rejected. A present token is still verified and

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we tighten the language so it's clear what a "failed" token is? It should be clear to users what the difference between IGNORED and OPTIONAL is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I updated the wordings to use "invalid" instead of "failed" (this came from Envoy), and also show the difference between the 3 options.

@sayap
sayap force-pushed the jwt-authn-presence-ignored branch from 2cac46c to 0561058 Compare October 21, 2026 12:57
@istio-testing istio-testing added the needs-rebase Indicates a PR needs to be rebased before being merged label Nov 3, 2026
@sayap
sayap force-pushed the jwt-authn-presence-ignored branch from 0561058 to 0996cc9 Compare November 3, 2026 23:08
@istio-testing istio-testing removed the needs-rebase Indicates a PR needs to be rebased before being merged label Nov 3, 2026
keithmattix
keithmattix previously approved these changes Nov 4, 2026
// `{"code": 3, "message": "Jwt is expired"}`. When there are multiple
// providers, each one should use its own key, otherwise failures can
// overwrite each other.
string failed_status_in_metadata = 16;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this should be failed_status_metadata_key but we can fix in a follow up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that's a good suggestion. I should rename it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed, let me update the PR title and description as well

`presence: IGNORED` makes the requirement always satisfied. In this
mode, requests with a missing token and requests with an invalid token
are both allowed.

`failedStatusMetadataKey`, if set, adds verification failure to the
dynamic metadata under this key, such that failures are always
observable regardless of the `presence` value.
@sayap
sayap force-pushed the jwt-authn-presence-ignored branch from 0996cc9 to 2d46074 Compare November 4, 2026 05:26
@sayap sayap changed the title feat: add presence: IGNORED and failedStatusInMetadata to JWTRule feat: add presence: IGNORED and failedStatusMetadataKey to JWTRule Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Set this label allow normal testing to take place for a PR not submitted by an Istio org member. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants