feat: Add optional issuer check to SessionManager authenticate - #440
feat: Add optional issuer check to SessionManager authenticate#440m0tzy wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
Original prompt from madison.packer
|
Greptile SummaryAdds optional issuer validation to session authentication while preserving existing behavior when no issuer is configured.
Confidence Score: 5/5The PR appears safe to merge, with the new issuer validation correctly opt-in and fail-closed when configured. The trailing optional parameters preserve existing callers, issuer claims are checked only after JWT signature and expiration validation, and validation failures remain within the established Important Files Changed
Reviews (1): Last reviewed commit: "Add optional issuer check to SessionMana..." | Re-trigger Greptile |
Summary
Lets apps opt in to validating the
issclaim of session access tokens. Part of the cross-SDK rollout started in workos/authkit-react-router#83 (see also workos/workos-node#1694, workos/workos-python#725, workos/workos-ruby#552). Default behavior is unchanged: with no issuer passed,issis not checked, exactly as before.SessionManageralready takes its session-verification inputs per call (clientId,baseUrl) rather than from client config, so the option follows that shape:decodeAccessToken()gets the same$issuerand, after signature +expchecks, requires$decoded['iss']to be a string inis_array($issuer) ? $issuer : [$issuer](strictin_array). A mismatch or missing claim surfaces as the existing['authenticated' => false, 'reason' => 'invalid_jwt']. An explicit[]fails closed (rejects every token) rather than disabling the check.refresh()does not decode a JWT, so it is untouched.Why not a client-level option:
WorkOS::__constructand theHttpClientwiring live in generatedlib/WorkOS.php(oagen), so a constructor/env option (WORKOS_ISSUER) would need an emitter change upstream; this PR stays inside the hand-maintainedSessionManager. The existing finding-#60 TODO about enforcingiss/audby default is kept and reworded.Tests:
./script/ci(php-cs-fixer, PHPStan, PHPUnit) passes — 357 tests. New cases cover unset, matching, mismatched, missingiss, list, and empty list.Link to Devin session: https://app.devin.ai/sessions/0ee38e859a9849658a7cdb2d215d89a6
Open in Devin Desktop: https://app.devin.ai/desktop/session/0ee38e859a9849658a7cdb2d215d89a6?variant=devin
Requested by: @m0tzy