auth

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HeimdallClaims

type HeimdallClaims struct {
	Principal string `json:"principal"`
	Email     string `json:"email,omitempty"`
}

HeimdallClaims contains extra custom claims we want to parse from the JWT token.

func (*HeimdallClaims) Validate

func (c *HeimdallClaims) Validate(_ context.Context) error

Validate provides additional middleware validation of any claims defined in HeimdallClaims.

type IJWTAuth

type IJWTAuth interface {
	ParsePrincipal(ctx context.Context, token string, logger *slog.Logger) (string, error)
}

IJWTAuth is a JWT authentication interface needed for the [ProjectsService].

type JWTAuth

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

func NewJWTAuth

func NewJWTAuth(config JWTAuthConfig) (*JWTAuth, error)

func (*JWTAuth) ParsePrincipal

func (j *JWTAuth) ParsePrincipal(ctx context.Context, token string, logger *slog.Logger) (string, error)

ParsePrincipal extracts the principal from the JWT claims.

type JWTAuthConfig

type JWTAuthConfig struct {
	// JWKSURL is the URL to the JSON Web Key Set endpoint
	JWKSURL string
	// Audience is the intended audience for the JWT token
	Audience string
	// MockLocalPrincipal is used for local development to bypass JWT validation
	MockLocalPrincipal string
}

JWTAuthConfig holds the configuration parameters for JWT authentication.

type MockJWTAuth

type MockJWTAuth struct {
	mock.Mock
}

MockJWTAuth implements JWTAuth for testing

func (*MockJWTAuth) ParsePrincipal

func (m *MockJWTAuth) ParsePrincipal(ctx context.Context, token string, logger *slog.Logger) (string, error)

Jump to

Keyboard shortcuts

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