fix: parse AuthKit Actions request into flat ActionContext - #115
Merged
Conversation
construct_action/4 deserialized the verified action request into the generic
EventSchema envelope ({object, id, event, data, created_at}). The real
Actions wire format is a flat context object discriminated by 'object'
(authentication_action_context / user_registration_action_context), so
parsing it into EventSchema silently dropped every useful field (user,
user_data, ip_address, device_fingerprint, issuer, ...) with no error.
Replace the EventSchema return with a typed WorkOS.ActionContext
(+ WorkOS.ActionUserData), mirroring workos-node's ActionContext and
reusing the generated User, Organization, OrganizationMembership, and
Invitation models for nested objects. Dispatch on :object to read the
type-specific fields.
Tests now exercise the real wire format for both context types; the prior
test used a fabricated event envelope that never matched what WorkOS sends.
Greptile SummaryThe PR replaces event-envelope parsing with typed, flat AuthKit action contexts and revises action-response serialization.
Confidence Score: 5/5The PR appears safe to merge because no eligible blocking failure or outstanding prior finding remains. No blocking failure remains. Important Files Changed
|
sign_response emitted a base64 {payload, sig} shape that no other SDK
produces. The real Actions response wire format (workos-node + python,
ruby, php, dotnet, kotlin) is {object, payload, signature}, where
signature = HMAC-SHA256(secret, "<timestamp>.<JSON(payload)>") and
payload = {timestamp, verdict, error_message?}.
Switch the return to %{object, payload, signature}, signing over
JSON.encode!(payload) so the signed bytes match the transmitted payload
bytes. error_message is included only on a Deny verdict with a non-empty
message, matching workos-node.
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
WorkOS.Actions.construct_action/4deserialized the verified AuthKit Action request into the genericWorkOS.EventSchemaenvelope ({object, id, event, data, created_at}). The real Actions wire format is a flat context object discriminated byobject(authentication_action_context/user_registration_action_context), not an event envelope — so parsing it intoEventSchemapopulated onlyobjectandid, leavingeventempty anddatanil. Every useful field (user,user_data,ip_address,user_agent,device_fingerprint,issuer,organization,invitation, …) was silently dropped with no error.This mirrors the bug reported against
workos-go(see workos-go #594 / PR #595).workos-nodeis the authoritative reference: itsActions.constructActiondeserializes into a flatActionContext(src/actions/interfaces/action.interface.ts).Changes
EventSchemareturn with a typedWorkOS.ActionContext(+WorkOS.ActionUserData), mirroringworkos-nodeand reusing the generatedUser,Organization,OrganizationMembership, andInvitationmodels for nested objects. Dispatch on:objectto read the type-specific fields.Validation
mix test test/workos/actions_test.exs→ 7 passedmix format --check-formattedcleanScope / follow-up
This fixes the request-parsing side (the reported bug). The response side (
sign_response/3) still emits the base64{payload, sig}shape, which differs fromworkos-node's{object, payload, signature}— that is a separate gap not addressed here.This is a breaking change to
construct_action's return type (EventSchema.t()→ActionContext.t()). The previous behavior never worked (every field was dropped), so no working code depends on the old return shape.