Persist Wix PKCE verifier per-state in DB and enforce one-time use#490
Open
AJaySi wants to merge 1 commit into
Open
Persist Wix PKCE verifier per-state in DB and enforce one-time use#490AJaySi wants to merge 1 commit into
AJaySi wants to merge 1 commit into
Conversation
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.
Motivation
code_verifierwith durable per-statestorage to support multi-process deployments and avoid instance-scoped secrets.stateso callers can retry cleanly.Description
wix_oauth_pkce_statestable and index and implementedstore_pkce_verifier,consume_pkce_verifier, andcleanup_expired_pkce_statesinservices/integrations/wix_oauth.pyto persist verifier + TTL and to atomically consume/invalidate it.WixService.get_authorization_urlto return a payload (authorization_url,state,code_verifier) instead of storing the verifier on the service instance and madeexchange_code_for_tokensrequire an explicitcode_verifierargument.GET /api/wix/auth/urlto require authentication, generate astatewhen absent, persist thecode_verifierfor the currentuser_idwith a short TTL, and return only the URL andstateto the client.POST /api/wix/auth/callbackandGET /api/wix/callbackto validate presence ofstate, look up and consume the verifier scoped to the authenticateduser_id, return a clear 400 error for invalid/expired states, and use the consumed verifier for token exchange and subsequent token storage.Testing
python -m py_compile backend/services/wix_service.py backend/services/integrations/wix_oauth.py backend/api/wix_routes.pyand it completed successfully.store_pkce_verifierandconsume_pkce_verifierand that callbacks return explicit 400 errors when astateis missing or invalid during local testing of the flow.Codex Task