Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSecurityModule ¶
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
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.