link

package
v0.3.0-rc.55 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 13 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 link signs requests for the alert and session pages people open from chat. Beacon stores the signing key and a revocation generation for each alert group or session. The method, exact path, expiry and generation are authenticated by HMAC-SHA256.

Index

Constants

View Source
const (
	// KeySize is the length of a signing key.
	KeySize = 32
	// Param is the query parameter that carries a signature.
	Param = "s"
	// DefaultTTL is how long a link stays valid unless the configuration says otherwise.
	DefaultTTL = 30 * 24 * time.Hour
)
View Source
const Root = "/console"

Root is where the console is, with the pages a link opens. Until 0.3.0 they were at the site's root, and the links handed out until then name those paths: Moved says which of them a link may still open.

Variables

View Source
var ErrKey = errors.New("the link key must be 32 bytes")

ErrKey means the key is not KeySize bytes.

Functions

func AlertPath

func AlertPath(id string) string

AlertPath is the path of an alert group's page.

func IncidentPath

func IncidentPath(id, episode string) string

IncidentPath pins an alert link to one episode of its recurring group.

func Moved

func Moved(old string) (string, bool)

Moved maps the path of a page as the links made before the console moved under Root named it (/alerts/{id}, /sessions/{id} and its recording) to the path the page has now; ok is false for any other path, which no link ever named.

func RecordingPath

func RecordingPath(id string) string

RecordingPath is the path of a session's recording, which its page plays.

func SessionPath

func SessionPath(id string) string

SessionPath is the path of a session's page.

func SignInPath

func SignInPath(next string) string

SignInPath opens a local page after the recipient signs in to the console.

func ValidEpisode

func ValidEpisode(episode string) bool

ValidEpisode reports whether episode identifies an individual incident.

Types

type Grant

type Grant struct {
	Until time.Time
	// contains filtered or unexported fields
}

Grant represents one verified signed request. Its authenticated limits are kept privately for deriving a canonical redirect or a recording link; Until is available to the page renderer.

type Pages

type Pages struct {
	Signer    *Signer
	PublicURL string
	// contains filtered or unexported fields
}

Pages builds the links to Beacon's pages: absolute under PublicURL and signed. A nil Pages, one without a signer or without a public URL builds none, so that callers can leave links out.

func (*Pages) Alert

func (p *Pages) Alert(id string) string

Alert is the link to an alert group's page.

func (*Pages) BaseURL

func (p *Pages) BaseURL() string

BaseURL returns the configured public base URL without a trailing slash.

func (*Pages) Incident

func (p *Pages) Incident(id, episode string) string

Incident is the signed link to an episode. Older groups without an episode use their group page.

func (*Pages) Session

func (p *Pages) Session(id string) string

Session is the link to a session's page, with its replay.

func (*Pages) SetPublicURL

func (p *Pages) SetPublicURL(u string)

SetPublicURL updates the public base URL used to build signed links.

func (*Pages) URL

func (p *Pages) URL(path string) string

URL is the signed link to the page at path (which begins with "/"), or "".

type Signer

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

Signer signs page paths and checks signatures.

func NewRevocableSigner

func NewRevocableSigner(key []byte, ttl time.Duration, now func() time.Time, generation func(kind, id string) (uint64, error)) (*Signer, error)

NewRevocableSigner makes a signer for alert and session paths backed by a durable generation.

func NewSigner

func NewSigner(key []byte, ttl time.Duration, now func() time.Time) (*Signer, error)

NewSigner makes a signer for exact paths without a revocation store. now may be nil.

func (*Signer) Derive

func (s *Signer) Derive(method, target string, grant Grant) string

Derive authenticates the same page, its supported canonical move, or the recording needed by its session replay. Derived links keep the verified expiry and generation, even if the resource is revoked between this check and use of the derived URL.

func (*Signer) Query

func (s *Signer) Query(path string) string

Query returns the query string that signs a GET of path, or an empty string on lookup failure.

func (*Signer) SetTTL

func (s *Signer) SetTTL(ttl time.Duration)

SetTTL updates how long newly signed links stay valid.

func (*Signer) Sign

func (s *Signer) Sign(method, path string) string

Sign returns the signature of method and path, valid for the signer's lifetime.

func (*Signer) SignUntil

func (s *Signer) SignUntil(method, path string, until time.Time) string

SignUntil returns a new signature valid until the second of until. If a generation lookup is required and fails, or if the path is outside the supported resources, it returns an empty string.

func (*Signer) TTL

func (s *Signer) TTL() time.Duration

TTL is how long the signer's links last.

func (*Signer) Verify

func (s *Signer) Verify(method, path, sig string) (time.Time, bool)

Verify checks sig for method and path and returns when it expires.

func (*Signer) VerifyGrant

func (s *Signer) VerifyGrant(method, path, sig string) (Grant, bool)

VerifyGrant checks a signature and the resource's current generation. Legacy two-part signatures authenticate generation zero and therefore stop working when the resource is first revoked.

Jump to

Keyboard shortcuts

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