Skip to content

Dashboard sign-in via GitHub device flow for relay-enrolled instances on any host #3867

Done

Description

@integry

Problem

A relay-enrolled instance (the zero-config ProPR App / Connect path, PROPR_GH_RELAY_URL + PROPR_GH_RELAY_TOKEN) has no usable dashboard sign-in on any host other than loopback. resolveBrowserAuthMode (packages/api/connectAuth.ts) returns:

  • connect only with a hosted Connect tunnel, or with a loopback callback;
  • github only with the instance's own OAuth client;
  • disabled otherwise.

So an instance on https://<app>.fly.dev, a VPS, or https://propr.internal.com needs its own GitHub OAuth App just to let people sign in. Because of this:

ui.gitfix.dev isn't affected: it owns propr-dev and signs in with that App's secret.

Solution: GitHub device flow sign-in

The device flow needs only the shared App's public client ID (propr-dev, Iv23liTCmmSNYyD0NtZA): no client secret and no callback URL. So it works on any hostname, port or private network, and ProPR's hosted services never handle the user token.

  1. New browser sign-in mode device.
    • resolveBrowserAuthMode picks it automatically for relay-enrolled instances that have neither their own OAuth client nor a usable Connect callback, instead of disabled.
    • It can also be chosen explicitly with PROPR_WEB_AUTH_MODE=device.
    • Keep the existing modes and their precedence otherwise. ui.gitfix.dev-style github mode is unchanged.
  2. Flow.
    • Login page: "Sign in with GitHub" → the API requests a device code (POST https://github.com/login/device/code, the client ID, no scopes beyond what sign-in needs).
    • The UI shows the user code with a copy button, plus a link that opens https://github.com/login/device.
    • The API polls https://github.com/login/oauth/access_token, honouring interval / slow_down / expires_in.
    • On success it calls GET /user and checks the user against the installation the same way the Connect path does today: the user must have access to the relay's installation. The user–installation check must be equivalent to Connect's, not weaker.
    • Then it creates the normal session.
    • Show the user code only to the browser that started the flow: bind it to a pending-login cookie, and use one code per attempt.
    • Rate-limit starts per IP and per session.
  3. Tokens. Treat the returned user token like the Connect path does: same use, same lifetime and renewal behavior where it applies (refresh token if the App issues expiring tokens), encrypted at rest. Never log it.
  4. Discovery of the client ID. Ship the shared App's client ID as a default, next to DEFAULT_PROPR_GH_RELAY_URL (packages/shared/src/proprServiceUrls.ts). Allow an override (PROPR_GH_DEVICE_CLIENT_ID), for example for a self-hosted relay with its own App.
  5. Clear errors. device_flow_disabled from GitHub → "Device sign-in isn't enabled for this GitHub App". Also handle access_denied, expired codes, and a user without installation access.
  6. Callers.
  7. Prerequisite (operator action): Device Flow has to be enabled on the propr-dev GitHub App. Until it is, GitHub returns device_flow_disabled. Tests mock GitHub; the live check happens once it's on.

Acceptance

  • Unit and integration tests:
    • mode resolution for every combination (own OAuth client, a tunnel, loopback, relay-only on a public host, relay-only on a private host);
    • the device flow (authorization_pending, slow_down, expired_token, access_denied, device_flow_disabled);
    • the installation access check;
    • session creation;
    • the token never appearing in logs or responses.
  • UI: the login page in device mode, light and dark, with the code, copy, the link, a waiting state and errors.
  • Docs: self-hosting / GitHub auth / Fly docs explain the device sign-in, when it's used, and how operators of their own App enable it.
  • Live (once Device Flow is on): a relay-only instance on https://<app>.fly.dev signs a browser in with no OAuth App of its own. Also check one non-Fly public host, or an internal hostname reached through a private network.

Activity

  1. propr-dev commented on Nov 27, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3867/claude-opus-5-5-dashboard-sign-in-via-git-20261127-2345-km7
    • Base Branch: 3758-epic-runtime-abstraction-sc0
    • Worktree: issue-3867-20261127-2345-claude-opus-5-5-km7

    🔍 Track Task Execution

  2. integry commented on Dec 1, 2026

    @integry
    OwnerAuthor

    Done in #3868, which merged into the runtime epic; the epic merged into main with #3774 and ships in 0.9.4.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions