fix(plugin-auth): harden all user-facing auth URLs to an absolute https origin#2865
Merged
Merged
Conversation
…ps origin Follow-up to the invitation-link fix (#2847). Audited every backend site that builds a user-facing link and found the same latent flaw: they read the raw `config.baseUrl`, so a bare-host value (no scheme) yielded relative-looking, unclickable links. Routed them all through the hardened getCanonicalOrigin(): - better-auth `baseURL` (583) — source of the reset-password / verify-email / magic-link email links. - OAuth `loginPage` / `consentPage` (1723-1724). - Device-authorization `verificationUri` (1811). - Phone-invite SMS `{{baseUrl}}` (sendPhoneInviteSms, 2201). Added tests: bare host promoted to https, explicit scheme/trailing slash preserved (getAuthIssuer), and better-auth baseURL carries the scheme. Full @objectstack/plugin-auth suite passes (406 tests). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NT4mx1fHXtkxery6MtLTsp
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 9 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
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.
Context
Follow-up to #2847 (invitation accept link). That PR fixed the invitation URL; this one audits every other backend site that builds a user-facing link and fixes the same latent flaw.
Problem
Several links were built from the raw
config.baseUrlwith no scheme guarantee, so a bare-hostbaseUrl(e.g.cloud.objectos.ai) produced relative-looking, unclickable links:baseURLauth-manager.ts:583loginPage/consentPageauth-manager.ts:1723-1724verificationUriauth-manager.ts:1811{{baseUrl}}sendPhoneInviteSms(:2201)Fix
All four now flow through the hardened
getCanonicalOrigin()(introduced in #2847), which prependshttps://when the scheme is missing and trims a trailing slash. Deployments that already set an absolutebaseUrlare unaffected (scheme preserved, only the trailing slash trimmed).Tests
getAuthIssuerlocks the normalization: bare host →https://…, explicit scheme + trailing slash preserved/trimmed (no doubling).baseURLcarries the scheme when configured as a bare host.@objectstack/plugin-authsuite passes (406 tests).Not included (need a product decision — flagged separately)
${origin}${uiBasePath}/login(or a set-password page). Only the scheme is fixed here.@objectstack/clientsignInWithProviderdefaultcallbackURL(client/src/index.ts:1667) defaults toorigin + '/login', missing the/_consoleprefix — left out because it changes a shared SDK's default behavior.Changeset
@objectstack/plugin-auth: patch.🤖 Generated with Claude Code
Generated by Claude Code