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

middleware

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package middleware holds the control-plane API server's net/http middleware (ADR-0018). authn resolves a static bearer token / scoped API key to an auth.Identity and gates every API request; unauthenticated requests get 401 problem+json. The spec/docs endpoints stay public.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authn

func Authn(creds CredentialStore) func(http.Handler) http.Handler

Authn returns middleware that authenticates each request: it reads the bearer token (Authorization: Bearer <t>) or the X-Api-Key header, resolves it via creds, and puts the Identity in the request context. Missing/unknown credentials → 401 problem+json (public spec/docs paths pass through).

func IdentityFrom

func IdentityFrom(ctx context.Context) (auth.Identity, bool)

IdentityFrom returns the authenticated Identity placed in ctx by Authn.

Types

type CredentialStore

type CredentialStore interface {
	Lookup(ctx context.Context, token string) (auth.Identity, error)
}

CredentialStore resolves an opaque bearer token / API key to an Identity. It returns fault.Unauthorized if the credential is unknown. The V1 implementation is an in-memory map built from config (NewStaticCredentials); OIDC is a V2 follow-on.

func NewStaticCredentials

func NewStaticCredentials(byToken map[string]auth.Identity) CredentialStore

NewStaticCredentials builds an in-memory CredentialStore from a token→Identity map.

Jump to

Keyboard shortcuts

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