Help us shape the future of Go! Take the 2026 Go Developer Survey

devtunnel

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Dev Tunnels authorization exchanges Microsoft or GitHub device codes for credentials accepted by the management service. It owns provider protocol details and validates bounded upstream responses, while callers own principal binding, admission, polling cadence, persistence, and public errors. DeviceAuthorization keeps the device code opaque and clears it when authorization reaches a terminal outcome.

Package devtunnel is the low-level Dev Tunnels management client. It creates, reads, and deletes Dev Tunnels and validates every host and URI the service returns. Credential is a connected account's bearer supplied by the caller rather than carried from the inbound request.

Index

Constants

View Source
const (
	MinDurationSeconds = uint32(60 * 60)
	MaxDurationSeconds = uint32(30 * 24 * 60 * 60)
)

Variables

View Source
var (
	ErrUnknownProvider          = errors.New("unknown Dev Tunnels authorization provider")
	ErrAuthorizationDenied      = errors.New("authorization for Dev Tunnels was denied")
	ErrAuthorizationExpired     = errors.New("authorization for Dev Tunnels expired")
	ErrAuthorizationUnavailable = errors.New("authorization for Dev Tunnels is unavailable")
	ErrAuthorizationInvalid     = errors.New("invalid Dev Tunnels authorization response")
	ErrAuthorizationRejected    = errors.New("authorization for Dev Tunnels was rejected")
)

Functions

func NewClient

func NewClient(baseURL string, httpClient *http.Client) (*client, error)

func ValidClusterID

func ValidClusterID(value string) bool

func ValidID

func ValidID(value string) bool

func ValidatePublicURI

func ValidatePublicURI(raw string) error

Types

type AuthorizationTokens

type AuthorizationTokens struct {
	Provider     string
	Scheme       string
	AccessToken  string
	RefreshToken string
	Account      string
	ExpiresIn    time.Duration
}

type Authorizer

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

func NewAuthorizer

func NewAuthorizer(client *http.Client) *Authorizer

func (*Authorizer) Poll

func (a *Authorizer) Poll(ctx context.Context, authorization *DeviceAuthorization, timeout time.Duration) (PollResult, error)

func (*Authorizer) Refresh

func (a *Authorizer) Refresh(ctx context.Context, providerName, refreshToken string) (AuthorizationTokens, error)

func (*Authorizer) Start

func (a *Authorizer) Start(ctx context.Context, providerName string) (*DeviceAuthorization, error)

func (*Authorizer) Supports

func (a *Authorizer) Supports(provider string) bool

type CreateRequest

type CreateRequest struct {
	Credential
	ID              string
	DurationSeconds uint32
	Ports           []PortSpec
}

type Credential

type Credential struct {
	Scheme, Token string
}

type DeleteRequest

type DeleteRequest struct {
	Credential
	ID        string
	ClusterID string
}

type DeviceAuthorization

type DeviceAuthorization struct {
	UserCode        string
	VerificationURI string
	ExpiresIn       time.Duration
	Interval        time.Duration
	// contains filtered or unexported fields
}

func (*DeviceAuthorization) Clear

func (a *DeviceAuthorization) Clear()

type GetRequest

type GetRequest struct {
	ConnectToken string
	ID           string
	ClusterID    string
}

type PollResult

type PollResult struct {
	Pending  bool
	SlowDown time.Duration
	Tokens   AuthorizationTokens
}

type PortRecord

type PortRecord struct {
	PortNumber         uint16
	Protocol           string
	PortForwardingURIs []string
}

type PortSpec

type PortSpec struct {
	PortNumber  uint16
	Description string
}

type Record

type Record struct {
	ID           string
	ClusterID    string
	ConnectToken string
	HostToken    string
	Ports        []PortRecord
	ExpiresAt    time.Time
}

func (Record) HTTPURI

func (r Record) HTTPURI(portNumber uint16) (string, error)

Jump to

Keyboard shortcuts

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