Skip to content

Preserve caller cancellation through metadata-based token verification #50

Open

Description

@joshuagay

At commit f44587f6317f886a2b7e1cbe081270ed55d6f8d8, caller cancellation during metadata discovery is converted into a token-validation failure.

VerifyAuthTokenWithJwksAsync() and VerifyWithJwksAsync() both pass the caller's cancellation token to metadata.FetchAsync(), then catch every Exception and wrap it in TokenVerificationException. These first and second catches include caller-triggered OperationCanceledException. Cancellation during the subsequent key fetch is outside those blocks, so the exception contract depends on the stage being cancelled.

The effect is visible beyond the exception wrapper: AuthTokenResponseValidator catches TokenVerificationException and returns IsValid=false. A cancelled validation can therefore look like a completed validation that rejected a credential.

Expected behavior: when the supplied caller token is cancelled, cancellation propagates consistently through both verification methods and the delivery validator. An application can distinguish an abandoned operation from invalid credentials.

Suggested regression tests: use a valid token fixture and an already-cancelled token, then repeat with an in-process metadata fetch whose wait is cancelled. Check both public verification methods and ValidateAsync(). The shared discovery fetch can retain its own bounded lifetime; preserving caller cancellation does not require cancelling work shared with other callers.

Suggested fix: exclude caller-requested cancellation from the error translation, while preserving the intended classification of actual discovery and verification failures.

Review basis: source inspection against the draft-10 SDK; this is an asynchronous API behavior issue, not a claim that a malformed token is accepted. No local .NET execution was available.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions