bearer

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// TokenPrefix is the expected prefix for bearer tokens
	TokenPrefix string `json:"tokenPrefix"`
	// ValidateIssuer checks the token issuer
	ValidateIssuer bool `json:"validateIssuer"`
	// RequireScopes enforces scope validation
	RequireScopes []string `json:"requireScopes"`
	// CaseSensitive makes token comparison case-sensitive
	CaseSensitive bool `json:"caseSensitive"`
}

Config holds the bearer plugin configuration

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns the default bearer plugin configuration

type Plugin

type Plugin struct {
	// contains filtered or unexported fields
}

Plugin implements bearer token authentication middleware

func NewPlugin

func NewPlugin(opts ...PluginOption) *Plugin

NewPlugin creates a new bearer token plugin with optional configuration

func (*Plugin) AuthenticateHandler

func (p *Plugin) AuthenticateHandler(next func(forge.Context) error) func(forge.Context) error

AuthenticateHandler returns a handler function that can be used as middleware

func (*Plugin) ID

func (p *Plugin) ID() string

ID returns the plugin identifier

func (*Plugin) Init

func (p *Plugin) Init(authInst core.Authsome) error

Init initializes the bearer plugin

func (*Plugin) RegisterServiceDecorators

func (p *Plugin) RegisterServiceDecorators(_ *registry.ServiceRegistry) error

RegisterServiceDecorators registers service decorators (no-op for bearer)

func (*Plugin) RequireAuthHandler

func (p *Plugin) RequireAuthHandler(next func(forge.Context) error) func(forge.Context) error

RequireAuthHandler returns a handler that requires authentication

type PluginOption

type PluginOption func(*Plugin)

PluginOption is a functional option for configuring the bearer plugin

func WithDefaultConfig

func WithDefaultConfig(cfg Config) PluginOption

WithDefaultConfig sets the default configuration for the plugin

func WithRequireScopes

func WithRequireScopes(scopes []string) PluginOption

WithRequireScopes sets the required scopes

func WithTokenPrefix

func WithTokenPrefix(prefix string) PluginOption

WithTokenPrefix sets the token prefix

func WithValidateIssuer

func WithValidateIssuer(validate bool) PluginOption

WithValidateIssuer sets whether to validate the issuer

Jump to

Keyboard shortcuts

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