Skip to content

feat(auth): track invalid oidc state token metrics - #4376

Open
shardool-patil wants to merge 2 commits into
zalando:masterfrom
shardool-patil:feat/oidc-track-invalid-token-metrics
Open

shardool-patil wants to merge 2 commits into
zalando:masterfrom
shardool-patil:feat/oidc-track-invalid-token-metrics

Conversation

@shardool-patil

Copy link
Copy Markdown
Contributor

Motivation

Resolves an existing TODO in getCallbackState where decryption failures on OIDC state parameters were unmonitored. Emitting metrics on invalid state tokens improves observability and alerts operators to potential token tampering, malformed callback requests, or replay attempts.

Summary

  • Export metric counter key oidcInvalidTokenMetric = "oidc.token.invalid".
  • Instrument getCallbackState in filters/auth/oidc.go to increment oidc.token.invalid via ctx.Metrics().IncCounter() when state decryption fails.
  • Add deterministic, table-driven test cases (TestGetCallbackState_InvalidStateTokenMetric) in filters/auth/oidc_test.go using metricstest.MockMetrics to verify:
    • Valid state parameters do not increment the counter.
    • Missing state query parameter fails without incrementing the decryption error counter.
    • Malformed hex encoding fails without incrementing the counter.
    • Corrupted/tampered state ciphertext triggers decryption failure and increments oidc.token.invalid.

Signed-off-by: Shardool Patil <shardoolpatil999@gmail.com>
@szuecs

szuecs commented Nov 4, 2026

Copy link
Copy Markdown
Member

@shardool-patil can you add the metric to docs/operations/operation.md ? Thanks, rest lgtm

@szuecs szuecs added monitoring Metrics related changes minor no risk changes, for example new filters labels Nov 4, 2026
Signed-off-by: Shardool Patil <shardoolpatil999@gmail.com>
@shardool-patil

shardool-patil commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

@shardool-patil can you add the metric to docs/operations/operation.md ? Thanks, rest lgtm

done added the required docs

This branch has not been deployed

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

Labels

minor no risk changes, for example new filters monitoring Metrics related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants