Documentation
¶
Index ¶
- func InitiateModule(moduleScope string, jwtScopes ...string) fx.Option
- type Config
- type Module
- func (m *Module) GenerateToken(scope string, additionalClaims jwt.MapClaims) (*string, error)
- func (m *Module) GetConfig(scope string) (*Config, error)
- func (m *Module) GetJWTMiddleware(scope string) echo.MiddlewareFunc
- func (m *Module) ParseToken(scope string, tokenString string) (jwt.MapClaims, error)
- func (m *Module) PrintDebugLogs()
- type Params
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitiateModule ¶
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 Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) GenerateToken ¶
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) GetJWTMiddleware ¶
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 ¶
parse JWT token for a specific scope
func (*Module) PrintDebugLogs ¶
func (m *Module) PrintDebugLogs()