wwwauth

package
v1.18.2 Latest Latest
Warning

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

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

Documentation

Overview

Package wwwauth builds RFC 6750 (OAuth 2.0 Bearer Token) WWW-Authenticate response headers. It is a small, dependency-free package so that both the api and auth packages can share a single RFC 6750 implementation without creating an import cycle (auth must not import api).

Index

Constants

View Source
const (
	// ErrInvalidRequest indicates the request is malformed or missing parameters.
	ErrInvalidRequest = "invalid_request"
	// ErrInvalidToken indicates the token is expired, revoked, or malformed.
	ErrInvalidToken = "invalid_token"
	// ErrInsufficientScope indicates the request requires higher privileges.
	ErrInsufficientScope = "insufficient_scope"
)

RFC 6750 section 3.1 error codes.

View Source
const Realm = "tmi"

Realm identifies the protection space for Bearer token authentication. This is a static value for TMI's API - all protected endpoints share the same realm.

Variables

This section is empty.

Functions

func BuildHeader

func BuildHeader(errType, description string) string

BuildHeader builds the value for a RFC 6750 compliant WWW-Authenticate header. Per RFC 6750 section 3, the value always includes the realm and optionally an error and error_description. This is the single source of truth for the header format so a compliance change lands in one place.

Parameters:

  • errType: Error code (invalid_request, invalid_token, insufficient_scope) or empty for a basic challenge
  • description: Human-readable error description (optional, ignored if errType is empty)

SEM@212287c6c02d99be7f8071b21a50666223646bec: build a RFC 6750 Bearer WWW-Authenticate header value (pure)

Types

This section is empty.

Jump to

Keyboard shortcuts

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