signin

package
v0.7.40-dev.1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package signin is a 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, and an OAuth connection of the runhost's own to a release's server, each run on the runhost while the person's browser is on the device.

A connection is the runhost's own grant, never a copy of the device's: the consent runs on the runhost as mcpauth.Consent does on a computer, its redirect relayed like ChatGPT's, and the runhost keeps the refresh token it is issued in its connection store, whose secrets are entries of its encrypted store. The device opens the consent only at the authorization endpoint it discovered for the server itself.

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 ConnectionVendor = "connection"

ConnectionVendor is the Kept.Vendor of an OAuth connection the runhost keeps for a release's server.

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 ConnectRequest added in v0.7.14

type ConnectRequest struct {
	// Ref, Digest and Server are the connection's key, as the runhost's
	// connection store and its schedules name it.
	Ref    string `json:"ref"`
	Digest string `json:"digest"`
	Server string `json:"server"`
	// URL is a remote server's address; Issuer, for a package server, the
	// authorization server its oauth block names. Exactly one is set.
	URL    string   `json:"url,omitempty"`
	Issuer string   `json:"issuer,omitempty"`
	Scopes []string `json:"scopes,omitempty"`
	// AgentryClient is the client id of Agentry's own public client for the
	// server's issuer, which the device resolved; "" for none.
	AgentryClient string `json:"agentryClient,omitempty"`
	// OwnClientID and OwnClientSecret are the person's own OAuth client for
	// the issuer, where the vendor takes no other.
	OwnClientID     string `json:"ownClientId,omitempty"`
	OwnClientSecret string `json:"ownClientSecret,omitempty"`
}

ConnectRequest asks the runhost to make a connection of its own to one of a release's servers: the person consents in the device's browser and the runhost keeps the grant it is issued, never a copy of the device's. Everything in it is what the consent needs; none of it is a token.

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 Connect added in v0.7.14

func Connect(ctx context.Context, c Caller, req ConnectRequest, authorize string, p Person) (Kept, error)

Connect makes the runhost's own connection req names, with the consent in the person's browser on this device, and answers with what the runhost kept. authorize is the authorization endpoint the device discovered for the server itself: the device opens no other page. Nothing of the grant reaches this device.

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)
	// Connections are the runhost's connection store and its store of the
	// person's own OAuth clients, which its schedules' connections are kept
	// in; nil for a runhost that keeps none.
	Connections func() (*connection.Store, *connection.Clients)
	// ConnectHTTP reaches a connection's vendor; nil is mcpauth.Guard's.
	ConnectHTTP func() *http.Client
	// CIMDURL is Agentry's client metadata document for a connection's
	// consent; "" leaves it out.
	CIMDURL string
	// 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) Connect added in v0.7.14

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

Connect makes the connection the request on in's first line names, unless the runhost already keeps a working one, and answers with what it kept. The rest of in stays open while the consent runs; its end tells the runhost the device has left.

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