feat: Add optional jwt_issuer option for session token validation - #552
feat: Add optional jwt_issuer option for session token validation#552m0tzy wants to merge 2 commits 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 for session access-token JWTs while preserving existing behavior when no issuer is configured.
Confidence Score: 5/5The PR appears safe to merge; no outstanding correctness, security, or repository-rule issues were identified. Issuer verification is enabled only when explicitly configured, global and direct client paths propagate the option consistently, and the updated test now constructs a token with the Important Files Changed
|
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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); default behavior is unchanged — no issuer configured meansissis not checked, exactly as before.WorkOS::BaseClient.new(..., jwt_issuer: nil)/config.jwt_issuer— aStringorArray<String>of accepted issuers, exposed asclient.jwt_issuer.WorkOS.clientforwards it from the global configuration.SessionManager#decode_jwtaddsiss: client.jwt_issuer, verify_iss: trueto theJWT.decodeoptions only whenjwt_issueris non-nil. ruby-jwt'sJWT::Claims::Issuermatches againstArray(issuers), so a list works natively, andInvalidIssuerError < DecodeErrormaps to the existingINVALID_JWTreason inSession#authenticate.WORKOS_ISSUERenv lookup here; passENV["WORKOS_ISSUER"]intoconfig.jwt_issueryourself if you want that.Not touched:
lib/workos/client.rbandrbi/**are oagen-generated.Clientinheritsinitializefrom the hand-maintainedBaseClient, so no generated change is needed for the kwarg; the.rbisignature forBaseClient#initialize/SessionManager#decode_jwtwill pick upjwt_issueron the next regen (CI does not type-check the rbi files).Tests:
standardrbclean;rake test1251 runs / 0 failures (Ruby 3.4). New cases cover unset, matching, mismatched, missingiss, list, empty list, andWorkOS.configurepropagation.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