Documentation ¶
Overview ¶
Package tokenmanager implements a simple JSON Web Token (JWT) and JSON Web Key (JWK) management system. It manages key rotation, token creation, and token validation.
Index ¶
- type TokenManager
- func (tm *TokenManager) CreateToken(claims jwt.Claims) (string, error)
- func (tm *TokenManager) KeyRotationLoop(ctx context.Context)
- func (tm *TokenManager) ServeJWKS(w http.ResponseWriter, req *http.Request)
- func (tm *TokenManager) ValidateToken(t string, opts ...jwt.ParserOption) (*jwt.Token, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TokenManager ¶
type TokenManager struct {
// contains filtered or unexported fields
}
TokenManager implements a simple JSON Web Token (JWT) and JSON Web Key (JWK) management system. It manages key rotation, token creation, and token validation.
func (*TokenManager) CreateToken ¶
func (tm *TokenManager) CreateToken(claims jwt.Claims) (string, error)
CreateToken creates a new JSON Web Token (JWT) with the provided claims.
func (*TokenManager) KeyRotationLoop ¶
func (tm *TokenManager) KeyRotationLoop(ctx context.Context)
KeyRotationLoop takes care of key rotation. It runs until ctx is canceled.
func (*TokenManager) ServeJWKS ¶
func (tm *TokenManager) ServeJWKS(w http.ResponseWriter, req *http.Request)
ServeJWKS returns the current public keys as a JSON Web Key Set (JWKS).
func (*TokenManager) ValidateToken ¶
func (tm *TokenManager) ValidateToken(t string, opts ...jwt.ParserOption) (*jwt.Token, error)
ValidateToken validates a JSON Web Token (JWT).
Click to show internal directories.
Click to hide internal directories.