jwt

package
v0.1.20 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitiateModule

func InitiateModule(moduleScope string, jwtScopes ...string) fx.Option

Initializes the JWT module with the provided jwtScopes. Takes multiple jwtScopes and loads configuration for each. Tokens can be generated for each scope.

For example: - jwt.GenerateToken("auth", jwt.MapClaims{"user_id": 123}) - jwt.GenerateToken("email", jwt.MapClaims{"email": "[email protected]"})

Types

type Config

type Config struct {
	TokenLookup   string
	SigningKey    string
	SigningMethod string
	ExpInHours    int
}

type Module

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

func (*Module) GenerateToken

func (m *Module) GenerateToken(scope string, additionalClaims jwt.MapClaims) (*string, error)

Generates a JWT token with the provided additional claims for a specific scope. Use jwt.MapClaims from "github.com/golang-jwt/jwt/v5"

func (*Module) GetConfig

func (m *Module) GetConfig(scope string) (*Config, error)

Retrieves the configuration for a specific scope.

func (*Module) ParseToken

func (m *Module) ParseToken(scope string, tokenString string) (jwt.MapClaims, error)

parse JWT token for a specific scope

func (*Module) PrintDebugLogs

func (m *Module) PrintDebugLogs()

Prints debug logs for all configurations.

type Params

type Params struct {
	fx.In

	Logger    *zap.Logger
	Lifecycle fx.Lifecycle
}

Jump to

Keyboard shortcuts

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