signin

package
v0.7.12-dev.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package signin is a model sign-in made for a remote runhost: Claude Code's own sign-in, Sign in with ChatGPT and Sign in with GitHub for a Copilot plan, run on the runhost while the person's browser is on the device.

The sign-in runs on the server exactly as it runs on a person's computer (claudesignin, modelsignin), into the runhost's own sign-in store: Claude Code keeps its credential in its docker volume there and refreshes it itself; ChatGPT's and Copilot's refresh tokens are kept in the runhost's encrypted store. Nothing of the sign-in is kept on the device. The device is asked to open each address in the person's browser, and where the browser's answer is a redirect to a loopback callback, the device listens on that port of its own loopback and relays each connection, byte for byte and unread, over a run key session of its own to the callback on the runhost: into Claude Code's container through exec, or to ChatGPT's loopback listener on the server. GitHub's device flow needs no relay: the device shows the code and opens GitHub's page.

Index

Constants

View Source
const MaxRelayed = 8

MaxRelayed bounds the connections relayed at once for one sign-in: a browser opens one or two for a callback.

Variables

Vendors are the sign-ins a runhost takes, in the order they are offered.

Functions

func IsVendor

func IsVendor(v string) bool

IsVendor says whether v is a sign-in a runhost takes.

Types

type Caller

type Caller interface {
	Call(ctx context.Context, verb string, args []string, send func(io.Writer) error, each func(runhost.Frame) error) (runhost.Answer, error)
}

Caller is the runhost connection a sign-in is made over: one Call for the sign-in and one for each relayed connection, all over the run key.

type Kept

type Kept struct {
	Vendor string `json:"vendor"`
	Kind   string `json:"kind"`
	Label  string `json:"label,omitempty"`
	// KeptAt is when it was kept, RFC 3339.
	KeptAt string `json:"keptAt,omitempty"`
	// Broken says why the vendor no longer honours it, when it does not.
	Broken string `json:"broken,omitempty"`
}

Kept is a sign-in the runhost keeps: never a token.

func Run

func Run(ctx context.Context, c Caller, vendor, app string, p Person) (Kept, error)

Run signs the runhost in to vendor, with the person's browser on this device, and answers with what the runhost kept. app is GitHub's app for Copilot. Nothing of the sign-in is kept on this device.

type Person

type Person struct {
	// Say tells the person what the runhost is doing.
	Say func(line string)
	// Open opens an address in the person's browser. It is handed only the
	// vendor's own sign-in pages.
	Open func(url string)
	// Code shows the code to enter on page (GitHub's device flow).
	Code func(page, code string)
	// Listen listens on the device's loopback; nil is net.Listen.
	Listen func(network, addr string) (net.Listener, error)
}

Person is the device's side of a sign-in on a runhost.

type Removed

type Removed struct {
	Vendor  string `json:"vendor"`
	Removed bool   `json:"removed"`
	// Outcome is the store's word on what the vendor was told.
	Outcome string `json:"outcome,omitempty"`
}

Removed is what removing a sign-in did.

type Server

type Server struct {
	// Home is the runhost account's runner home, whose sign-in store the
	// runhost's runs read.
	Home string
	// Keys keeps the refresh tokens: the runhost's encrypted store.
	Keys connection.Keychain
	// PolicyPath is the runhost's own policy file, which Claude Code's image
	// is prepared under.
	PolicyPath string
	// Docker is the server's daemon; nil is dockerx.New.
	Docker func() dockerx.Client
	// ChatGPT and GitHub are the vendors' flows, with only their HTTP client
	// and endpoints set; the server sets the rest.
	ChatGPT func() mcpauth.ChatGPT
	GitHub  func() mcpauth.GitHub
	// Dial reaches a loopback callback on the server; nil is net.Dialer's.
	Dial func(ctx context.Context, addr string) (net.Conn, error)
	// contains filtered or unexported fields
}

Server runs sign-ins on the runhost, one at a time, for devices that relay the browser's answer to it.

func (*Server) HasSignIn

func (s *Server) HasSignIn(kind string) error

HasSignIn says whether the runhost keeps a working sign-in of kind, and if not, why.

func (*Server) List

func (s *Server) List() ([]Kept, error)

List is the sign-ins the runhost keeps.

func (*Server) Relay

func (s *Server) Relay(ctx context.Context, id string, in io.Reader, fw *runhost.FrameWriter) (int, error)

Relay carries one browser connection, in from the device and out in data frames, to the callback of the sign-in id names. It returns when either side closes, or when the sign-in ends.

func (*Server) Remove

func (s *Server) Remove(ctx context.Context, vendor string, out io.Writer) (Removed, error)

Remove ends vendor's sign-in on the runhost: Claude Code's own logout and its volume deleted, or the refresh token revoked at the vendor where it can be and deleted from the store.

func (*Server) Start

func (s *Server) Start(ctx context.Context, vendor, app string, in io.Reader, fw *runhost.FrameWriter) (int, error)

Start runs vendor's sign-in for the device on the other end of in and fw, and answers with what it kept. app is GitHub's app for Copilot ("" for the GitHub App). The device's leaving (in ends) ends the sign-in.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL