Allow pluggable encryptors for session seal/unseal#432
Merged
gjtorikian merged 1 commit intomainfrom Feb 4, 2026
Merged
Conversation
Greptile OverviewGreptile SummaryThis PR refactors session encryption to support pluggable encryptors, allowing users to bring their own encryption implementation (e.g., Iron seal/unseal for Next.js compatibility). Key Changes:
Architecture: Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant UserManagement
participant Session
participant AuthResponse
participant Encryptor
Note over User,Encryptor: Authentication Flow with Custom Encryptor
User->>UserManagement: load_sealed_session(encryptor: custom_encryptor)
UserManagement->>Session: new(encryptor: custom_encryptor)
Session->>Session: validate_encryptor!(encryptor)
Note over Session: Validates encryptor responds to #seal and #unseal
Session->>Session: @encryptor = custom_encryptor || AesGcm.new
User->>Session: authenticate()
Session->>Encryptor: unseal(session_data, cookie_password)
Encryptor-->>Session: unsealed session data
Session->>Session: JWT.decode(access_token)
Session-->>User: authentication result
User->>Session: refresh()
Session->>Encryptor: unseal(session_data, cookie_password)
Encryptor-->>Session: unsealed session data
Session->>UserManagement: authenticate_with_refresh_token(session: {encryptor: @encryptor})
UserManagement->>AuthResponse: new(response, session)
AuthResponse->>Session: seal_data(data, key, encryptor: session[:encryptor])
Session->>Encryptor: seal(data, key)
Encryptor-->>Session: sealed session
Session-->>AuthResponse: sealed_session
AuthResponse-->>UserManagement: authentication_response
UserManagement-->>Session: auth_response
Session-->>User: refresh result with new sealed_session
|
ericroberts
approved these changes
Feb 4, 2026
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.
Description
Update to #430, this allows users to BYO encryptor for sealed sessions, if they're not using our default of
aes_gcm.@molly-higgins when this PR is merged and released, you should be able to run:
MyApp::IronSealUnsealwill need to define its ownsealandunsealmethods.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.