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
- Variables
- func AlertPath(id string) string
- func IncidentPath(id, episode string) string
- func Moved(old string) (string, bool)
- func RecordingPath(id string) string
- func SessionPath(id string) string
- func SignInPath(next string) string
- func ValidEpisode(episode string) bool
- type Grant
- type Pages
- type Signer
- func (s *Signer) Derive(method, target string, grant Grant) string
- func (s *Signer) Query(path string) string
- func (s *Signer) SetTTL(ttl time.Duration)
- func (s *Signer) Sign(method, path string) string
- func (s *Signer) SignUntil(method, path string, until time.Time) string
- func (s *Signer) TTL() time.Duration
- func (s *Signer) Verify(method, path, sig string) (time.Time, bool)
- func (s *Signer) VerifyGrant(method, path, sig string) (Grant, bool)
Constants ¶
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 )
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 ¶
var ErrKey = errors.New("the link key must be 32 bytes")
ErrKey means the key is not KeySize bytes.
Functions ¶
func IncidentPath ¶
IncidentPath pins an alert link to one episode of its recurring group.
func Moved ¶
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 ¶
RecordingPath is the path of a session's recording, which its page plays.
func SignInPath ¶
SignInPath opens a local page after the recipient signs in to the console.
func ValidEpisode ¶
ValidEpisode reports whether episode identifies an individual incident.
Types ¶
type Grant ¶
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 ¶
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) Incident ¶
Incident is the signed link to an episode. Older groups without an episode use their group page.
func (*Pages) SetPublicURL ¶
SetPublicURL updates the public base URL used to build signed links.
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 ¶
NewSigner makes a signer for exact paths without a revocation store. now may be nil.
func (*Signer) Derive ¶
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 ¶
Query returns the query string that signs a GET of path, or an empty string on lookup failure.
func (*Signer) Sign ¶
Sign returns the signature of method and path, valid for the signer's lifetime.
func (*Signer) SignUntil ¶
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.