tokenauth

package
v0.9.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BearerAuthMiddleware

func BearerAuthMiddleware(expectedToken string) func(http.Handler) http.Handler

BearerAuthMiddleware creates middleware that validates Bearer token authentication If expectedToken is empty, the middleware allows all requests (backwards compatibility)

func GenerateToken

func GenerateToken() (string, error)

GenerateToken generates a cryptographically secure random token suitable for use as an API bearer token. The token is 32 bytes of random data encoded as base64url (resulting in ~44 characters).

func ReadToken

func ReadToken(tokenFile string) (string, error)

ReadToken reads the API token from the specified file or environment variable If tokenFile is empty, only the environment variable is read Priority: file > environment variable > empty (no auth) Returns empty string (no error) if no token is configured

Types

This section is empty.

Jump to

Keyboard shortcuts

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