token

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package token mints and validates Atlas's opaque share tokens.

A share token is the whole authorization for an unauthenticated URL: a public process start link (ADR-0029) or a shared documentation version (ADR-0143) is readable by whoever holds the token and nobody else. Two properties follow, and they are why this is a package rather than a helper beside one of its callers:

  • It must be unguessable, so it is 32 bytes of CSPRNG output. There is nothing to brute-force and nothing to derive it from.
  • It must be *shaped*, because these tokens name their own files on disk. A token that is not bare hex is refused before it reaches the filesystem, which is what stops a request-supplied one from addressing a path (see api/sidecar, whose stores apply the same predicate to keys on the way in).

Both callers use the same two functions, so a token minted by one is valid by the other's rule — the alternative, a second copy of the hex check, is how the two definitions drift apart and one of them stops refusing something.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHex

func IsHex(s string) bool

IsHex reports whether s has the shape New produces: non-empty, even-length, hex. It is the guard that keeps a token supplied by a request from naming a foreign file or traversing out of the directory it is looked up in, so it is applied before a token is ever used as a path.

func New

func New() (string, error)

New mints a fresh opaque token: 32 random bytes as lowercase hex.

Types

This section is empty.

Jump to

Keyboard shortcuts

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