feat: Add optional issuer check to SessionManager authenticate - #440
Merged
Merged
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
🤖 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
|
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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