Documentation ¶
Overview ¶
Package JWT contains functions required for JWT signing and validation.
Currently only PS512 algorithm is supported, more methods will be added in future releases.
Index ¶
- type Claims
- type Manager
- func (m Manager) CreateCustom(dat interface{}, expiresAt *time.Time) (<-chan string, <-chan error)deprecated
- func (m Manager) ParseCustom(token string) (<-chan *Claims, <-chan error)
- func (m Manager) SignCustom(claims *Claims) (<-chan string, <-chan error)
- func (m Manager) ValidateCustom(token string) (<-chan interface{}, <-chan error)deprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct { Dat interface{} `json:"dat,omitempty"` *jwt.StandardClaims }
Claims represents a custom claim where the dat section is used for custom data.
TODO: make this generic in 2.0
func NewClaims ¶ added in v1.2.0
func NewClaims() *Claims
NewClaims creates a new instance of the custom JWT claims.
TODO: make this generic in 2.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is responsible for creating and validating JWT tokens.
Given that validating JWT comes with a hefty cost, internally, the manager caches already validated tokens, so if the same token is validated repeatedly, cached results will be returned.
func NewManager
deprecated
func NewManager(publicKey *rsa.PublicKey, privateKey *rsa.PrivateKey) Manager
NewManager creates a new JWT client that signs and validates JWT tokens using the PS512 algorithm.
Deprecated: Instead of using this method, users of the library should use NewPS512Manager instead. The underlying source code has already been converted to use the new function, and all users should also do so.
This method will be removed in the 2.0 version stream when we implement generics.
func NewPS512Manager ¶ added in v1.2.0
func NewPS512Manager(publicKey *rsa.PublicKey, privateKey *rsa.PrivateKey) Manager
NewPS512Manager creates a new JWT client that signs and validates JWT tokens using the PS512 algorithm.
func (Manager) CreateCustom
deprecated
CreateCustom creates a JWT token with custom dat claim.
Deprecated: Instead of using this method, users of the library should create the Claims object separately and use the SignCustom function instead. The underlying source code has already been converted to use the new function, and all users should also do so.
This method will be removed in the 2.0 version stream when we implement generics.
func (Manager) ParseCustom ¶ added in v1.2.0
ParseCustom parses a JWT token with the claims and returns the claims of the token.
TODO: make this generic in 2.0
func (Manager) SignCustom ¶ added in v1.2.0
SignCustom signs the JWT token with the given claims.
TODO: make this generic in 2.0
func (Manager) ValidateCustom
deprecated
ValidateCustom validates a JWT token with a custom dat claim.
Deprecated: Instead of using this method, users of the library should use ParseCustom function instead, and subsequently work directly with the Claims object that the function returns. The underlying source code has already been converted to use the new function, and all users should also do so.
This method will be removed in the 2.0 version stream when we implement generics.