Skip to content

fix: isolate Passport strategies per authentication request - #658

Merged
david-loe merged 1 commit into
mainfrom
fix/passport-strategy-race-condition
Nov 11, 2026
Merged

david-loe merged 1 commit into
mainfrom
fix/passport-strategy-race-condition

Conversation

@david-loe

@david-loe david-loe commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Passing a shared strategy instance to passport.authenticate lets overlapping requests overwrite Passport's request-specific callbacks on the singleton. Clone the strategy with Object.create(strategy) for each bearer authentication attempt, covering both httpBearer and usageToken.

Keep the original strategy reference for the existing httpBearerStrategy identity check and activity recording. The change is limited to one line in backend/controller/authentication.ts.

Validation:

  • Docker Compose images built for common, backend, LDAP and Inbucket.
  • Common TypeScript build passed.
  • Backend npm test passed: tsoa generation, TypeScript compilation and all 440 existing tests, including the User API scenario containing personal API key activity persistence and throttling.
  • Biome 2.6.4 CI check passed for the changed file with --error-on-warnings.
  • No new regression tests added, as requested.

Summary by CodeRabbit

  • Bug Fixes
    • Authentication now uses an isolated copy of the selected sign-in configuration. Existing session handling, callbacks, and sign-in options remain unchanged, so the authentication flow should behave as before while avoiding unintended changes to the original configuration. No new sign-in steps or user-facing options have been added.

@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

bearerAuthentication now passes a shallow copy of the selected Passport strategy to passport.authenticate. The session option and callback are unchanged.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Possibly related PRs

  • david-loe/abrechnung#634: Adds activity recording to successful httpBearerStrategy authentication in the same bearerAuthentication flow.
Merge Risk: Minimal · up to c7bc0

The change isolates the bearer strategy for each authentication request. No actionable merge-blocking risk remains.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: isolating Passport strategies for each authentication request.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 61a27fe and c7bc011.

Files selected for processing: 1

  • backend/controller/authentication.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@david-loe
david-loe merged commit 7ab8070 into main Nov 11, 2026
10 checks passed
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