Skip to content

docs(security): document constant-time-comparison contract for auth callbacks#457

Merged
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:sec/lens5-timing
May 14, 2026
Merged

docs(security): document constant-time-comparison contract for auth callbacks#457
fredbi merged 1 commit into
go-openapi:masterfrom
fredbi:sec/lens5-timing

Conversation

@fredbi
Copy link
Copy Markdown
Member

@fredbi fredbi commented May 14, 2026

The runtime delegates credential comparison to caller-supplied authentication callbacks (UserPassAuthentication, TokenAuthentication, ScopedTokenAuthentication, and their Ctx variants). Callers that compare a secret against a known value must use
crypto/subtle.ConstantTimeCompare to avoid response-timing side-channels.

This commit:

  • Documents the contract on all six callback type godocs.
  • Updates the apikey and basic auth examples to demonstrate the safe pattern, so users copying the snippets inherit it.

No API change. The runtime itself does not compare secrets and remains structurally timing-safe.

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

…allbacks

The runtime delegates credential comparison to caller-supplied
authentication callbacks (UserPassAuthentication, TokenAuthentication,
ScopedTokenAuthentication, and their Ctx variants). Callers that
compare a secret against a known value must use
crypto/subtle.ConstantTimeCompare to avoid response-timing side-channels.

This commit:
- Documents the contract on all six callback type godocs.
- Updates the apikey and basic auth examples to demonstrate the
  safe pattern, so users copying the snippets inherit it.

No API change. The runtime itself does not compare secrets and
remains structurally timing-safe.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@fredbi fredbi force-pushed the sec/lens5-timing branch from 872ed62 to 9881e97 Compare May 14, 2026 22:43
@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.38%. Comparing base (1e4d68e) to head (9881e97).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #457   +/-   ##
=======================================
  Coverage   83.38%   83.38%           
=======================================
  Files          62       62           
  Lines        4388     4388           
=======================================
  Hits         3659     3659           
  Misses        569      569           
  Partials      160      160           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fredbi fredbi merged commit d5b684b into go-openapi:master May 14, 2026
23 checks passed
@fredbi fredbi deleted the sec/lens5-timing branch May 14, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant