fix: forward an={account} on VTEX ID outbound calls - #697
Conversation
|
Beep boop 🤖 Thank you so much for keeping our documentation up-to-date ❤️ |
|
Hi! I'm VTEX IO CI/CD Bot and I'll be helping you to publish your app! 🤖 Please select which version do you want to release:
And then you just need to merge your PR when you are ready! There is no need to create a release commit/tag.
|
b2abcab to
e9332ee
Compare
The axios-based callers in `node/resolvers/auth` and
`node/resolvers/profile/services` were hitting `vtexid.vtex.com.br`
without the `an={account}` query string, causing the backend to
reject some flows (e.g. `accesskey/send` returning HTTP 401 on
master, which the same call returns 200 once `an=` is present).
Adds `?an={account}` to:
- `pub/authentication/accesskey/validate`
- `pub/authentication/accesskey/send`
- `pub/authentication/classic/validate`
- `pub/authentication/classic/setpassword`
- `pvt/user/detailedinfo`
`pub/authentication/start` (sessionToken) is intentionally kept
without `an`: the backend validates that the host of `callbackUrl`
and `returnUrl` matches the account in `an`, which would break
callers that pass relative URLs (`/`).
Co-authored-by: Cursor <cursoragent@cursor.com>
e9332ee to
dfc0790
Compare
|
Your PR has been merged! App is being published. 🚀 After the publishing process has been completed (check #vtex-io-releases) and doing A/B tests with the new version, you can deploy your release by running:
After that your app will be updated on all accounts. For more information on the deployment process check the docs. 📖 |

Summary
Some axios-based callers in
node/resolvers/authandnode/resolvers/profile/serviceswere hittingvtexid.vtex.com.brwithout thean={account}query string. This caused the backend to reject some flows in production — for example,pub/authentication/accesskey/sendreturns HTTP 401 fromstorecomponents/masterand the same call returns 200 oncean=storecomponentsis present (validated below).This change adds
?an={account}to every direct call that previously omitted it, while keeping the host (vtexid.vtex.com.br) and the route shape unchanged.Endpoints touched
pub/authentication/accesskey/validateanpub/authentication/accesskey/sendanpub/authentication/classic/validateanpub/authentication/classic/setpasswordanpvt/user/detailedinfoanpub/authentication/start(sessionToken)pub/authentication/startis left withoutanbecause the backend validates that the host ofcallbackUrlandreturnUrlmatches the account inan. Callers in this codebase pass relative URLs (/), so addinganthere returns HTTP 400 (The host and {callbackUrl,returnUrl} accounts do not match).getAuthenticatedUserandIdentityClient.getUserWithTokenalready propagatean(viaJanusClientand explicitly, respectively);loginSessions/logOutFromSessionalready hadanin the URL.Files
node/resolvers/paths.ts— URL builders acceptaccountand append&an=${account}.node/resolvers/auth/index.ts— 5 call sites passioContext.account.node/__tests__/resolvers/paths.test.ts— 7 unit tests for the URL builders (including a regression guard forloginSessions/logOutFromSessionand an explicit assertion thatsessionTokendoes not carryan).CHANGELOG.md— entry under[Unreleased] - Fixed.Test plan
Unit suite (
node/):yarn test→ 871/871 green.End-to-end via curl, comparing
storecomponents/master(production, without the fix) againststorecomponents/vulnsg(with this branch linked):loginOptionsqueryclassicSignInmutation (invalid creds)WrongCredentialsWrongCredentials(byte-identical)sendEmailVerificationmutation (fresh email){ sendEmailVerification: true }(200 OK)Direct curls to
vtexid.vtex.com.brconfirmed thataccesskey/{validate,send},classic/{validate,setpassword}andpvt/user/detailedinfoacceptan=without changing the response shape; onlypub/authentication/startrejectsanwhencallbackUrl/returnUrlare relative — hence the carve-out.