Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func KeyIDFromContext ¶
KeyIDFromContext returns the authenticated key id, or "" if unauthenticated.
func New ¶
New returns middleware that requires a Bearer token matching one of the keys currently held by store, AND that the matching key has the requiredScope. The store snapshot is read per request, so a SIGHUP-triggered reload takes effect on the next inbound request.
On failure: 401 (no/invalid token) or 403 (missing scope), with a JSON body.
Types ¶
type KeyStore ¶
type KeyStore struct {
// contains filtered or unexported fields
}
KeyStore is an atomically-swappable snapshot of the bearer-key list. It is safe for concurrent Load() and Store() — readers see either the previous snapshot or the new one, never a partial mix.
The middleware reads the snapshot per-request, so a SIGHUP reload in main is reflected on the next inbound request without restarting the process or interrupting any in-flight stream.
func NewKeyStore ¶
NewKeyStore returns a store seeded with the initial key list.