Help us shape the future of Go! Take the 2026 Go Developer Survey

signedurl

package
v0.32.0 Latest Latest
Warning

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

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

Documentation

Overview

Package signedurl provides HMAC-signed URLs for media requests from devices that cannot pass cookies (AirPlay, Chromecast).

Index

Constants

View Source
const (
	CIDParam     = "cid"
	ExpiresParam = "expires"
	SigParam     = "signature"
)

Variables

View Source
var (
	ErrMissingParams    = errors.New("missing required signed URL parameters")
	ErrExpiredURL       = errors.New("signed URL has expired")
	ErrInvalidSignature = errors.New("invalid signature")
	ErrInvalidURL       = errors.New("invalid URL")
)

Functions

func DerivePrefix

func DerivePrefix(path string) string

DerivePrefix extracts the signing prefix from a request path by taking the first 3 segments and stripping the file extension from the 3rd.

func GenerateCredentialID

func GenerateCredentialID(secret []byte, username string) string

GenerateCredentialID produces an opaque, deterministic identifier for a user. It is an HMAC-SHA256 of the username, truncated to 16 hex characters.

func SignPrefix

func SignPrefix(prefix string, secret []byte, cid string, expires time.Time) url.Values

SignPrefix signs a path prefix and returns url.Values containing the cid, expires, and signature parameters. The caller appends these to any URL whose path falls under the signed prefix.

func VerifyURL

func VerifyURL(requestPath string, queryParams url.Values, secret []byte) (string, error)

VerifyURL verifies a signed URL request. It derives the signing prefix from the request path, checks expiry, and validates the HMAC signature. Returns the credential ID on success.

Types

This section is empty.

Jump to

Keyboard shortcuts

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