Skip to content

fix(setup): derive signin URL from api_url for self-hosted instances - #131

Open
manumishra12 wants to merge 1 commit into
HexmosTech:mainfrom
manumishra12:fix/self-hosted-signin-url
Open

manumishra12 wants to merge 1 commit into
HexmosTech:mainfrom
manumishra12:fix/self-hosted-signin-url

Conversation

@manumishra12

@manumishra12 manumishra12 commented Jun 19, 2026 •

Copy link
Copy Markdown

Summary

Fixes #28 — when git-lrc is configured against a self-hosted LiveReview instance, the signin / "Re-authenticate" flow always redirected to the cloud hexmos.com domain instead of the self-hosted server. Self-hosted users saw not authenticated, and clicking Re-authenticate bounced them to hexmos.com even though review-on-commit requests were correctly going to their local instance.

Root cause

runHexmosLoginFlow already had the configured apiURL in scope (self-hosted-aware), but BuildSigninURL(callbackURL) ignored it and always parsed the hardcoded cloud constant HexmosSigninBase = "https://hexmos.com/signin". Both initial setup and the UI re-authenticate button share this code path, so both were affected.

Fix

Thread apiURL into BuildSigninURL and resolve the signin base via a new ResolveSigninBase(apiURL) with this precedence:

  1. LRC_SIGNIN_URL env override, if set;
  2. cloud default (hexmos.com/signin) when api_url is empty or the cloud URL — cloud behavior is unchanged;
  3. otherwise <api_url>/signin, so a self-hosted instance signs in against itself.

Also relaxed the signin base validation to allow http (local self-hosted instances), still requiring a valid scheme and a non-empty host. The <api_url>/signin derivation mirrors the existing network/endpoints.go convention (strings.TrimSuffix(apiURL, "/") + path).

⚠️ Note for maintainers

The <api_url>/signin path is a reasonable assumption — I couldn't find a documented convention in the repo for where a self-hosted LiveReview serves its signin page. If that path is wrong, the LRC_SIGNIN_URL override means self-hosters aren't blocked, but please confirm the correct path so the derived default can be corrected if needed.

Testing

  • go build ./..., go vet, gofmt -l all clean
  • setup and internal/appui packages pass, including new BuildSigninURL tests covering: cloud default, empty api_url, self-hosted derivation, trailing-slash api_url, and the LRC_SIGNIN_URL override.

🔍 LiveReview

Auto-approval decisions

Review Decision Reason
#12675 ❌ Not approved Risk score 1.00 (P50) is above the cutoff of 1.00 (P20); Disqualifying class: security-sensitive

⚙️ Customize risk-based approval policy for this repository or your organization.

The signin/re-authenticate flow always redirected to the cloud
hexmos.com domain, even when git-lrc was configured against a
self-hosted LiveReview instance. BuildSigninURL ignored the api_url
and always parsed the hardcoded HexmosSigninBase constant, so
self-hosted users saw 'not authenticated' and re-auth bounced them
to hexmos.com instead of their own server.

Thread api_url into BuildSigninURL and resolve the signin base via
ResolveSigninBase:
  1. LRC_SIGNIN_URL override, if set;
  2. cloud default (hexmos.com/signin) when api_url is empty or the
     cloud URL -- cloud behavior is unchanged;
  3. otherwise <api_url>/signin, so a self-hosted instance signs in
     against itself.

Also relax the signin base to allow http (local self-hosted
instances), still requiring a valid scheme and host. Covers both
initial setup and the UI re-authenticate button, which share this
code path.

Fixes HexmosTech#28
@livereview-agent

Copy link
Copy Markdown

Enable Self-Hosted Signin URL Resolution

Overview

Resolve signin URLs dynamically using the active API URL or environment overrides. This update allows authentication flows against self-hosted and local environments alongside default cloud endpoints.

Technical Highlights

  • setup/login_server.go: Add ResolveSigninBase to resolve endpoints via LRC_SIGNIN_URL, cloud defaults, or API URL derivation.
  • setup/login_server.go: Allow HTTP schemes in BuildSigninURL to support local and non-TLS self-hosted instances.
  • internal/appui/setup_flow.go: Forward the active apiURL to BuildSigninURL during interactive setup.
  • setup/login_server_test.go: Add unit test coverage for scheme handling, trailing slashes, empty inputs, and environment overrides.

Impact

  • Functionality: Users can authenticate CLI sessions against self-hosted and custom server deployments.
  • Risk: Allowing HTTP schemes introduces plaintext credential risks on insecure networks.

Comment thread setup/login_server.go
}

apiURL = strings.TrimSpace(apiURL)
if apiURL == "" || apiURL == CloudAPIURL {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: warning

Trailing slash in apiURL prevents matching CloudAPIURL, incorrectly deriving a self-hosted signin URL.

Suggestions:

  1. Normalize apiURL and CloudAPIURL by trimming trailing slashes before equality comparison.

Comment thread setup/login_server.go
return "", fmt.Errorf("api url must include a host for signin derivation")
}

return strings.TrimSuffix(apiURL, "/") + "/signin", nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Severity: warning

String concatenation appends /signin after query parameters or URL fragments if present in apiURL.

Suggestions:

  1. Construct the signin path using base.JoinPath("signin").String() instead of string concatenation.

@livereview-agent livereview-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ LiveReview policy: Not approved (blocked at Risk score) · Review #12675

Stage Result Detail
Eligibility ✅ author level 1 >= required 1
Static rules ✅ no blocking rulesets configured
Risk score ❌ Risk score 1.00 (P50) is above the cutoff of 1.00 (P20)
LLM classification ❌ disqualifying class: security-sensitive
Final decision ❌ risk: Risk score 1.00 (P50) is above the cutoff of 1.00 (P20); llm: disqualifying class: security-sensitive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

git-lrc ui issues with self-hosted LiveReview

1 participant