auth

package
v0.1.0-rc.49 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: BSD-3-Clause Imports: 28 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

package clientauth separates ordinary authenticated requests from explicit login. Authenticate reuses an explicit access token or a saved control session and may refresh it; only Login and StartLogin initiate human approval.

device login checkpoints live in server-scoped client state. private device challenges, nonces, assertions, and issued sessions use its secret protector. waiters share an operation lock; credential locks cover refresh, cancellation, and installation, never browser approval. revisions reject cancelled work, and installation commits the session, selected server, and completion together.

checkpoints precede one-time redemption and control exchange. after a lost response or process exit during those steps, the operation requires a new login instead of replaying a potentially consumed credential. an assertion or issued session already checkpointed can resume without another redemption.

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthenticationTimeout = errors.New("clientauth: authentication timed out")
View Source
var ErrDeploymentCredential = failure.Wrap("read deployment credential", failure.Authentication, errors.New("deployment credential is invalid or expired; create a current credential with tnl auth credential create"))

Functions

func CancelLogin

func CancelLogin(ctx context.Context, config Config, id string) (clientstate.AuthOperation, error)

func InspectLogin

func InspectLogin(ctx context.Context, config Config, id string) (clientstate.AuthOperation, error)

func Logout

func Logout(ctx context.Context, config Config) error

func RequireSignInOutsideDemo

func RequireSignInOutsideDemo(ctx context.Context, state *clientstate.Database, serverURL, accessToken string) error

func StartLogin

func StartLogin(ctx context.Context, config Config) (clientstate.AuthOperation, error)

StartLogin returns immediately after creating a durable device challenge.

func WaitLogin

func WaitLogin(ctx context.Context, config Config, id string, timeout time.Duration) (result clientstate.AuthOperation, retErr error)

WaitLogin joins one operation. its file lock is separate from credential refresh/install, and cancellation uses revision checks rather than this lock.

Types

type Client

type Client struct {
	ServerEndpoint string
	Discovery      controlv1.ControlDiscovery
	Control        *clientcontrol.Client
	Authority      *clientauthority.Client
}

func Authenticate

func Authenticate(ctx context.Context, config Config) (*Client, error)

func Login

func Login(ctx context.Context, config Config) (*Client, error)

Login uses the same durable control-owned operation as start/wait.

type Config

type Config struct {
	Team                 string
	ServerEndpoint       string
	State                *clientstate.Database
	AccessToken          string
	HTTPClient           *http.Client
	Diagnostics          io.Writer
	OpenURL              func(string) error
	AuthenticationPrompt func(Prompt) error
	ObserveLogin         func(clientstate.AuthOperation) error
	LoginTimeout         time.Duration
}

type DeploymentCredential

type DeploymentCredential struct {
	Version    int                            `json:"version"`
	ControlURL string                         `json:"control_url"`
	Team       string                         `json:"team"`
	Approval   controlv1.DeploymentCredential `json:"approval"`
	PrivateKey string                         `json:"private_key"`
}

the portable value selects a signing key and server, not authority. control checks the current key, grant, deployments and service approvals on every use.

func ParseDeploymentCredential

func ParseDeploymentCredential(token string) (DeploymentCredential, error)

func RegisterDeploymentCredential

func RegisterDeploymentCredential(ctx context.Context, store *clientstate.Store, control *clientcontrol.Client, server, teamID, teamName, project, requestKey string, request controlv1.RegisterDeploymentCredentialRequest) (DeploymentCredential, error)

setup keeps the original key in protected client state before the HTTP call. a lost reply retries the same registration; neither retries nor exports rotate it.

func (DeploymentCredential) CaptureSigner

func (c DeploymentCredential) CaptureSigner() (*DeploymentSigner, error)

func (DeploymentCredential) Encode

func (c DeploymentCredential) Encode() (string, error)

func (DeploymentCredential) GoString

func (DeploymentCredential) GoString() string

func (DeploymentCredential) PublicKey

func (c DeploymentCredential) PublicKey() (ed25519.PublicKey, error)

func (DeploymentCredential) SelectProject

func (c DeploymentCredential) SelectProject(project string) error

matches friendly project selection without a checkout or a team-list request. the exact team ID in approval is used on the wire; a matching name grants nothing.

func (DeploymentCredential) Sign

func (c DeploymentCredential) Sign(message []byte) ([]byte, error)

func (DeploymentCredential) String

func (DeploymentCredential) String() string

func (DeploymentCredential) Subject

type DeploymentSigner

type DeploymentSigner struct {
	// contains filtered or unexported fields
}

DeploymentSigner retains a validated signing operation, not serving permission. negative cleanup can still use it after the portable approval has expired.

func (*DeploymentSigner) GoString

func (*DeploymentSigner) GoString() string

func (*DeploymentSigner) PublicKey

func (s *DeploymentSigner) PublicKey() ed25519.PublicKey

func (*DeploymentSigner) Sign

func (s *DeploymentSigner) Sign(message []byte) []byte

func (*DeploymentSigner) String

func (*DeploymentSigner) String() string

type DeploymentTokenSource

type DeploymentTokenSource struct {
	Credential DeploymentCredential
	// contains filtered or unexported fields
}

each application owner has a bounded token cache. no signing key or bearer is written to connection snapshots, registry records, command arguments or logs.

func NewDeploymentTokenSource

func NewDeploymentTokenSource(c DeploymentCredential, httpClient *http.Client) (*DeploymentTokenSource, error)

func (*DeploymentTokenSource) ExpiresAt

func (s *DeploymentTokenSource) ExpiresAt() time.Time

func (*DeploymentTokenSource) GoString

func (*DeploymentTokenSource) GoString() string

func (*DeploymentTokenSource) String

func (*DeploymentTokenSource) String() string

func (*DeploymentTokenSource) Token

type Prompt

type Prompt struct{ URL, Code string }

Prompt contains the control-owned approval URL and code shown by the CLI.

type StatusResult

type StatusResult struct {
	SchemaVersion    int        `json:"schema_version"`
	Server           string     `json:"server"`
	Status           string     `json:"status"`
	Source           string     `json:"source"`
	AccessExpiresAt  *time.Time `json:"access_expires_at,omitempty"`
	RefreshExpiresAt *time.Time `json:"refresh_expires_at,omitempty"`
	Checked          bool       `json:"checked"`
}

func Status

func Status(ctx context.Context, config Config, check bool) (StatusResult, error)

Status is local unless check is requested. checking may refresh credentials and validate with control, but never initiates approval or browser login.

Jump to

Keyboard shortcuts

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