credentials

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: 9 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 credentials creates and validates typed credentials.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidAccessToken is returned for malformed or rejected access tokens.
	ErrInvalidAccessToken = errors.New("invalid access token")
	// ErrInvalidRefreshToken is returned for malformed or rejected refresh tokens.
	ErrInvalidRefreshToken = errors.New("invalid refresh token")
	// ErrInvalidInvitationToken is returned for malformed or rejected invitation tokens.
	ErrInvalidInvitationToken = errors.New("invalid invitation token")
	// ErrInvalidPublisherConnectionCredential is returned for malformed publisher connection credentials.
	ErrInvalidPublisherConnectionCredential = errors.New("invalid publisher connection credential")
)
View Source
var ErrInvalidAssignmentSeed = errors.New("invalid assignment seed")
View Source
var ErrInvalidAuthorization = errors.New("invalid authorization header")
View Source
var ErrInvalidCredentialID = errors.New("invalid credential ID")

ErrInvalidCredentialID is returned for malformed credential lookup IDs.

View Source
var ErrInvalidServiceRunToken = errors.New("invalid managed run token")

Functions

func Bearer

func Bearer(headers http.Header) (string, error)

Bearer extracts one opaque token from exactly one Authorization header. the scheme is case-insensitive; whitespace and comma-combined tokens are rejected. it does not validate a credential class or authenticate its holder.

func DeriveAssignmentCredential

func DeriveAssignmentCredential(seed AssignmentSeed, assignmentContext string) (PublisherConnectionCredential, SecretHash, error)

func DeriveInvitationToken

func DeriveInvitationToken(retrySecret []byte, retryContext string) (InvitationToken, SecretHash, error)

DeriveInvitationToken returns the same one-time invitation secret when a request is retried with the same secret and context.

func NewAccessToken

func NewAccessToken() (AccessToken, CredentialID, SecretHash, error)

NewAccessToken creates an access token and its storage values.

func NewInvitationToken

func NewInvitationToken() (InvitationToken, SecretHash, error)

NewInvitationToken creates a one-time team invitation token.

func NewPublisherConnectionCredential

func NewPublisherConnectionCredential() (PublisherConnectionCredential, SecretHash, error)

NewPublisherConnectionCredential creates a credential for one connection assignment.

func NewRefreshToken

func NewRefreshToken() (RefreshToken, CredentialID, SecretHash, error)

NewRefreshToken creates a control-session refresh token and its storage values.

func NewServiceRunToken

func NewServiceRunToken() (ServiceRunToken, SecretHash, error)

func ParseAccessToken

func ParseAccessToken(token AccessToken) (CredentialID, SecretHash, error)

ParseAccessToken validates an access token and returns its storage lookup values.

func ParseAssignmentSeed

func ParseAssignmentSeed(seed AssignmentSeed) error

func ParseRefreshToken

func ParseRefreshToken(token RefreshToken) (CredentialID, SecretHash, error)

ParseRefreshToken validates a refresh token and returns its storage lookup values.

func SecretHashMatches

func SecretHashMatches(stored []byte, candidate SecretHash) bool

SecretHashMatches compares a stored digest without data-dependent timing.

Types

type AccessToken

type AccessToken string

AccessToken authenticates an identity to the tnl server API.

func (AccessToken) String

func (t AccessToken) String() string

String returns the serialized access token.

type AssignmentSeed

type AssignmentSeed string

AssignmentSeed derives publisher connection credentials, not service run tokens.

func NewAssignmentSeed

func NewAssignmentSeed() (AssignmentSeed, error)

func (AssignmentSeed) String

func (s AssignmentSeed) String() string

type CredentialID

type CredentialID string

CredentialID is the nonsecret lookup portion of a credential.

func ParseCredentialID

func ParseCredentialID(value string) (CredentialID, error)

ParseCredentialID validates a canonical nonsecret credential lookup ID.

func (CredentialID) String

func (id CredentialID) String() string

String returns the nonsecret credential ID.

type InvitationToken

type InvitationToken string

InvitationToken authorizes accepting one team invitation.

func (InvitationToken) String

func (t InvitationToken) String() string

String returns the serialized invitation token.

type PublisherConnectionCredential

type PublisherConnectionCredential string

PublisherConnectionCredential authorizes one publisher connection assignment claim.

func (PublisherConnectionCredential) String

String returns the serialized publisher connection credential.

type RefreshToken

type RefreshToken string

RefreshToken rotates one control session's access and refresh credentials.

func (RefreshToken) String

func (t RefreshToken) String() string

String returns the serialized refresh token.

type SecretHash

type SecretHash [sha256.Size]byte

SecretHash is the stored digest of a random token secret.

func ParseInvitationToken

func ParseInvitationToken(token InvitationToken) (SecretHash, error)

ParseInvitationToken validates an invitation token and returns its stored digest.

func ParsePublisherConnectionCredential

func ParsePublisherConnectionCredential(credential PublisherConnectionCredential) (SecretHash, error)

ParsePublisherConnectionCredential validates a publisher connection credential and returns its stored hash.

func ParseServiceRunToken

func ParseServiceRunToken(token ServiceRunToken) (SecretHash, error)

ParseServiceRunToken accepts only the canonical, unprefixed secret.

type ServiceRunToken

type ServiceRunToken string

ServiceRunToken authorizes one service run, independently of publisher connection derivation seeds.

func (ServiceRunToken) String

func (t ServiceRunToken) String() string

Jump to

Keyboard shortcuts

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