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 ¶
- Variables
- func CancelLogin(ctx context.Context, config Config, id string) (clientstate.AuthOperation, error)
- func InspectLogin(ctx context.Context, config Config, id string) (clientstate.AuthOperation, error)
- func Logout(ctx context.Context, config Config) error
- func RequireSignInOutsideDemo(ctx context.Context, state *clientstate.Database, ...) error
- func StartLogin(ctx context.Context, config Config) (clientstate.AuthOperation, error)
- func WaitLogin(ctx context.Context, config Config, id string, timeout time.Duration) (result clientstate.AuthOperation, retErr error)
- type Client
- type Config
- type DeploymentCredential
- func (c DeploymentCredential) CaptureSigner() (*DeploymentSigner, error)
- func (c DeploymentCredential) Encode() (string, error)
- func (DeploymentCredential) GoString() string
- func (c DeploymentCredential) PublicKey() (ed25519.PublicKey, error)
- func (c DeploymentCredential) SelectProject(project string) error
- func (c DeploymentCredential) Sign(message []byte) ([]byte, error)
- func (DeploymentCredential) String() string
- func (c DeploymentCredential) Subject() tunnelv1.VisitorSubject
- type DeploymentSigner
- type DeploymentTokenSource
- type Prompt
- type StatusResult
Constants ¶
This section is empty.
Variables ¶
var ErrAuthenticationTimeout = errors.New("clientauth: authentication timed out")
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 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
}
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 ¶
func (c DeploymentCredential) Subject() tunnelv1.VisitorSubject
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
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"`
}