Documentation
¶
Index ¶
- Variables
- type Algorithm
- type Body
- type ES256Signer
- type ES256Verifier
- type Header
- type Signer
- type Token
- func (t *Token) AddClaim(name string, value interface{})
- func (t *Token) AddScope(scope string)
- func (t *Token) GetClaim(name string) (interface{}, bool)
- func (t *Token) GetStringClaim(name string) (string, bool)
- func (t *Token) HasScope(scope string) bool
- func (t *Token) IsSigned() bool
- func (t *Token) RemoveClaim(name string)
- func (t *Token) RemoveScope(scope string)
- func (t *Token) Serialize() (string, error)
- func (t *Token) Sign(signer Signer) error
- func (t *Token) Verify(verifier Verifier) bool
- type Verifier
Constants ¶
This section is empty.
Variables ¶
var ErrImmutable = errors.New("the operation cannot complete as the token is immutable")
ErrImmutable is returned when an operation cannot be completed due to the token being signed.
var ErrInvalidTokenStructure = errors.New("the provided token is invalid")
ErrInvalidTokenStructure is returned when the provided token has an invalid structure and is not semantically a JWT.
Functions ¶
This section is empty.
Types ¶
type Algorithm ¶
type Algorithm string
Algorithm is an alias for string that defines the set of supported JWT signature types.
type Body ¶
type Body map[string]interface{}
Body represents the main structure of the token for scopes and claims.
type ES256Signer ¶
type ES256Signer struct {
// contains filtered or unexported fields
}
ES256Signer signs JWT tokens using the ES256 algorithm.
func NewES256Signer ¶
func NewES256Signer(privateKey *ecdsa.PrivateKey) *ES256Signer
NewES256Signer creates a new ES256Signer with the provided ECDSA Private Key.
func (*ES256Signer) Algorithm ¶
func (s *ES256Signer) Algorithm() Algorithm
Algorithm returns ES256.
type ES256Verifier ¶
type ES256Verifier struct {
// contains filtered or unexported fields
}
ES256Verifier verifies JWT tokens using the ES256 algorithm.
func NewES256Verifier ¶
func NewES256Verifier(publicKey *ecdsa.PublicKey) *ES256Verifier
NewES256Verifier creates a new ES256Verifier with the provided ECDSA Public Key.
type Token ¶
Token represents a (potentially signed) JWT token.
func (*Token) AddScope ¶
AddScope adds a scope to the token. This operation is a no-op if the token is signed.
func (*Token) GetStringClaim ¶
GetStringClaim gets the string value of a claim, if present.
func (*Token) IsSigned ¶
IsSigned returns true when the token has a signature present. This method does not state anything about the validity of an attached signature.
func (*Token) RemoveClaim ¶
RemoveClaim removes a claim from the token.
func (*Token) RemoveScope ¶
RemoveScope removes a scope from the token. This operation is a no-op if the token is signed.