jwt_manager

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 10 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) GetJWTMiddleware

func (m *Module) GetJWTMiddleware(scope string) echo.MiddlewareFunc

Returns a pointer to an echo.MiddlewareFunc that provides JWT authentication middleware for Echo framework. Middleware validates the JWT token, parses claims, and stores them in context under the key "user".

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()

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
JackTT - Gopher 🇻🇳