Repository navigation
[haxcms-nodejs] Login returns siteToken with the JWT - #79
Merged
Merged
Conversation
…lt; login returns siteToken Follow-up to #71. The webcomponents front-end now stores the request tokens that login, refresh and connection-test return (haxtheweb/webcomponents PR, jwt-login session-tokens event), so anonymous connection-settings loads no longer need them. - security.requireSessionForRequestTokens now defaults to TRUE. A boolean in config.json is used as-is (false opts out); strings go through the 1/true/yes list; anything else falls back to the default. The env var HAXCMS_REQUIRE_SESSION_FOR_REQUEST_TOKENS still overrides both ways. - login now returns the same request tokens as refresh/connection-test: userToken always, siteToken when a site context resolves (body, path, Referer, single-site). An in-page login on a site page can save without waiting for the first refresh. - loginRoute is async (getSessionRequestTokens resolves the single-site context); session.js already awaits it. - tests: default on, boolean/string/other config resolution, opt-out keeps the old anonymous behaviour, login from a site page returns siteToken, failed login carries no tokens. Do not merge until src/public/build carries the new front-end: with the old build, anonymous editor loads have no tokens and in-page login loops. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013J4JEf3WfrBgaePbuRC7uF
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Resolve the HAXCMS.js conflict with main's Prettier reformat by taking main's file and re-applying getRequireSessionForRequestTokens (default true, booleans used as-is) in the new style. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013J4JEf3WfrBgaePbuRC7uF
main's security update already flips requireSessionForRequestTokens to default on (same semantics as haxcms-php L-3), so take main's HAXCMS.js and session tests. What this PR still adds: login returns siteToken too (getSessionRequestTokens, async route), the test helper awaits the async route, and tests for login from a site page and a failed login. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013J4JEf3WfrBgaePbuRC7uF
btopro
marked this pull request as ready for review
October 19, 2026 20:31
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Follow-up to #71 and haxtheweb/webcomponents#882. Parity PR: haxtheweb/haxcms-php#662.
Scope after today's
mainupdatesThe default flip of
security.requireSessionForRequestTokens(on by default) has already landed onmain, in your own commit01b1762, together with the haxtheweb/webcomponents#882 build (2e2eda5). I mergedmainin and took its versions ofHAXCMS.jsand the flag tests. This PR is now just the login part:siteTokentoo. It now usesgetSessionRequestTokens(req), the same helper refresh and connection-test use.userTokenis always returned;siteTokenis returned when a site context resolves (body, path, Referer, single-site). With anonymousconnection-settingsno longer handing out tokens, this lets an in-page login on a site page save straight away instead of waiting for the first refresh.loginRouteis nowasync.session.jsalready awaits it.src/systemRoutes/v1/routes/login.jsObject.assign({status, jwt}, getSessionRequestTokens(req)), with auserTokenfallback if that throwstest/unit/session-hardening.test.cjsrealLoginand the login test await the async route; new tests: login from a site page returns that site'ssiteToken, and a failed login carries no tokensTests
npm testlocally: 2689 pass, 0 fail.npm run test:coveragealso passes locally.https://claude.ai/code/session_013J4JEf3WfrBgaePbuRC7uF
Generated by Claude Code