security

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSecurityModule

func NewSecurityModule(opts ...Option) fx.Option

NewSecurityModule provides security functionality: SecurityHandler for token validation.

Options:

  • WithTokenConfig: provide static token Config (useful for tests)
  • WithoutSecurity: bypass security, returns admin claims (useful for unit tests)
  • WithTestValidator: use base64 JSON tokens (useful for e2e tests)

Example usage:

// Production - validates PASETO tokens
security.NewSecurityModule()

// Unit tests - bypass security completely
security.NewSecurityModule(
    security.WithoutSecurity(),
)

// E2E tests - use base64 JSON tokens with realistic flow
security.NewSecurityModule(
    security.WithTestValidator(),
)

Types

type Option added in v0.4.3

type Option func(*securityOptions)

Option is a functional option for configuring the security module.

func WithTestValidator added in v0.4.3

func WithTestValidator() Option

WithTestValidator enables the test validator that decodes base64-encoded JSON tokens. Use token.GenerateTestToken or token.GenerateAdminTestToken to create tokens. Useful for e2e/integration tests where you want realistic token flow without PASETO.

func WithTokenConfig added in v0.4.3

func WithTokenConfig(cfg token.Config) Option

WithTokenConfig provides a static token Config (useful for tests). When set, the token configuration will not be loaded from viper.

func WithoutSecurity added in v0.4.3

func WithoutSecurity() Option

WithoutSecurity disables token validation and returns admin claims. Useful for unit tests where security is not the focus.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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