jointoken

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package jointoken is the codec for the compact join token that carries admin access to a freshly bootstrapped single-VPS k3s cluster from `burrow bootstrap` (run once on the VPS) to `burrow join` (run on the laptop) — ADR-0044. The bootstrap has the k3s admin kubeconfig rewritten to the node's public IP; it encodes the parts of that kubeconfig into one paste-able string, and the laptop decodes it to record admin access locally and land the scoped agent credential (ADR-0038).

The token is ADMIN-grade: it carries the cluster's admin credential (a client cert+key, or a bearer token), so it must be handled like a kubeconfig — transmitted over a private channel, not logged, and not committed. It is deliberately self-contained (no network round-trip to decode) and versioned so the format can evolve.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encode

func Encode(t Token) (string, error)

Encode validates the token, JSON-marshals it, and returns the one-line, paste-able string "burrowjoin.v1.<base64url>" (URL-safe base64, no padding). It defaults Version to the current schema version. The returned string is ADMIN-grade; see the package doc.

Types

type Token

type Token struct {
	// Version is the payload schema version; it must equal the prefix's version ("v1" today).
	Version string `json:"version"`
	// Server is the API server URL, e.g. https://<public-ip>:6443.
	Server string `json:"server"`
	// CertificateAuthorityData is the cluster CA certificate (PEM bytes).
	CertificateAuthorityData []byte `json:"certificateAuthorityData"`
	// ClientCertificateData and ClientKeyData carry the admin client certificate and key (k3s's
	// admin credential). Both are set together, or both empty when BearerToken is used instead.
	ClientCertificateData []byte `json:"clientCertificateData,omitempty"`
	ClientKeyData         []byte `json:"clientKeyData,omitempty"`
	// BearerToken is an admin bearer token, the alternative to the client cert+key. Exactly one of
	// {client cert+key, bearer token} is present in a valid token.
	BearerToken string `json:"bearerToken,omitempty"`
	// Namespace is the burrowd control-plane namespace on the bootstrapped cluster.
	Namespace string `json:"namespace"`
	// ContextName is the kube context (and cluster) name to record admin access under locally, and
	// the name the environment handle points at.
	ContextName string `json:"contextName"`
}

Token is the decoded join token (ADR-0044). It carries everything `burrow join` needs to reach the freshly bootstrapped cluster as admin and to record it locally:

  • Server + CertificateAuthorityData locate and authenticate the API server;
  • exactly one admin credential form — a client cert+key (k3s's admin) or a bearer token;
  • Namespace is the burrowd control-plane namespace on the cluster;
  • ContextName is the kube context/cluster name to record admin access under locally.

It is ADMIN-grade (see the package doc): treat a Token, and its encoded form, like a kubeconfig.

func Decode

func Decode(s string) (Token, error)

Decode parses a one-line join token produced by Encode. It rejects a missing or wrong version prefix, malformed base64, malformed JSON, a payload version that disagrees with the prefix, and a token that fails validation. Surrounding whitespace is tolerated.

Jump to

Keyboard shortcuts

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