brokered

package
v0.7.17-dev.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package brokered is the sealed answer of a sign-in the registry completes for a person's own machine: the tokens of a vendor whose token endpoint needs a client secret, which the registry adds to the exchange or the refresh and never keeps.

The machine makes a key pair for the one request and sends the public half with it. The registry's worker, which alone holds the secret, seals the tokens to that key with HPKE (RFC 9180), binding in what the request was for: the registry, the account, the kind of request and its id. The registry hands the sealed value over once and keeps nothing it can open; only the private half, which never leaves the machine and is used once, opens it, and only for that request.

Index

Constants

View Source
const (
	// MaxPublicKey is the longest public key a request may carry.
	MaxPublicKey = 4096
	// MaxTokens is the longest answer, as JSON, a seal carries.
	MaxTokens = 32 << 10
)

The bounds of a request and its answer.

View Source
const (
	// KindConsent answers a sign-in: the tokens its exchange gave.
	KindConsent = "consent"
	// KindRefresh answers a refresh of a connection already made.
	KindRefresh = "refresh"
)

The kinds of request an answer is for.

View Source
const Suite = "hpke-mlkem768x25519-hkdfsha256-chacha20poly1305"

Suite names the HPKE suite an answer is sealed with: ML-KEM-768 with X25519 (X-Wing), HKDF-SHA256 and ChaCha20-Poly1305.

Variables

This section is empty.

Functions

func CheckPublicKey

func CheckPublicKey(publicKey []byte) error

CheckPublicKey reports whether publicKey is one of Suite's, for a registry to refuse a request it could never answer.

func Seal

func Seal(publicKey []byte, b Binding, t Tokens) ([]byte, error)

Seal seals t to the machine's public key for b. A public key that is not one of Suite's, or tokens without an access token, an issuer or a client, are refused before anything is sealed.

Types

type Binding

type Binding struct {
	// Registry is the registry's origin.
	Registry string `json:"registry"`
	// Account is the account id the request was made as.
	Account string `json:"account"`
	// Kind is KindConsent or KindRefresh, and Request that request's id.
	Kind    string `json:"kind"`
	Request string `json:"request"`
}

Binding is what one answer is for. Every field is bound into the seal.

type Key

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

Key is a machine's key pair for one request. Its private half stays in memory and is dropped after the one Open.

func NewKey

func NewKey() (*Key, error)

NewKey makes a fresh key pair for one request.

func (*Key) Open

func (k *Key) Open(b Binding, sealed []byte) (*Tokens, error)

Open opens an answer sealed for b with this key pair.

func (*Key) PublicKey

func (k *Key) PublicKey() []byte

PublicKey is the public half the machine sends with its request.

type Tokens

type Tokens struct {
	AccessToken  string    `json:"accessToken"`
	RefreshToken string    `json:"refreshToken,omitempty"`
	ExpiresAt    time.Time `json:"expiresAt,omitzero"`
	Scopes       []string  `json:"scopes,omitempty"`
	// Issuer and ClientID are the authorization server and the
	// deployment's client the tokens belong to.
	Issuer   string `json:"issuer"`
	ClientID string `json:"clientId"`
}

Tokens is what an answer carries: the vendor's tokens, and the client they were made with, so the machine refreshes through the registry with the same one.

Jump to

Keyboard shortcuts

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