Documentation ¶
Index ¶
Constants ¶
View Source
const ( // V1 defines protocol version 1 V1 = Version("v1") // V2 defines protocol version 1 V2 = Version("v2") )
Variables ¶
View Source
var ( // ErrUnsupportedTokenVersion unsupported parser version ErrUnsupportedTokenVersion = errors.New("unsupported parser version") // ErrUnsupportedTokenType unsupported token type ErrUnsupportedTokenType = errors.New("unsupported token type") // ErrIncorrectPrivateKeyType incorrect private key type ErrIncorrectPrivateKeyType = errors.New("incorrect private key type") // ErrIncorrectPublicKeyType incorrect public key type ErrIncorrectPublicKeyType = errors.New("incorrect public key type") // ErrPublicKeyNotFound public key for this version not found ErrPublicKeyNotFound = errors.New("public key for this version not found") // ErrIncorrectTokenFormat incorrect token format ErrIncorrectTokenFormat = errors.New("incorrect token format") // ErrIncorrectTokenHeader incorrect token header ErrIncorrectTokenHeader = errors.New("incorrect token header") // ErrInvalidTokenAuth invalid token authentication ErrInvalidTokenAuth = errors.New("invalid token authentication") // ErrInvalidSignature invalid signature ErrInvalidSignature = errors.New("invalid signature") // ErrDataUnmarshal can't unmarshal token data to the given type of value ErrDataUnmarshal = errors.New("can't unmarshal token data to the given type of value") )
Functions ¶
func GetTokenInfo ¶
GetTokenInfo returns token version and purpose
func ParseFooter ¶
ParseFooter parses footer from token
func WithFooter ¶
func WithFooter(footer interface{}) func(*options)
WithFooter adds footer to the token
Types ¶
type JSONToken ¶ added in v0.2.0
type JSONToken struct { Audience string Issuer string Jti string Subject string Expiration time.Time IssuedAt time.Time NotBefore time.Time // contains filtered or unexported fields }
JSONToken defines predefined token payload struct
func (JSONToken) MarshalJSON ¶ added in v0.2.0
MarshalJSON implements json.Marshaler interface
func (*JSONToken) UnmarshalJSON ¶ added in v0.2.0
UnmarshalJSON implements json.Unmarshaler interface
type Protocol ¶
type Protocol interface { // Encrypt encrypts token with symmetric key Encrypt(key []byte, payload interface{}, options ...opsFunc) (string, error) // Decrypt decrypts key encrypted with symmetric key Decrypt(token string, key []byte, payload interface{}, footer interface{}) error // Sign signs token with given private key Sign(privateKey crypto.PrivateKey, payload interface{}, options ...opsFunc) (string, error) // Verify verifies token with given public key Verify(token string, publicKey crypto.PublicKey, value interface{}, footer interface{}) error }
Protocol defines PASETO tokes protocol
type Validator ¶ added in v0.2.0
Validator defines JSONToken validator function
func ForAudience ¶ added in v0.2.0
ForAudience validates JSONToken audience
func IdentifiedBy ¶ added in v0.2.0
IdentifiedBy validates JSONToken JTI
Click to show internal directories.
Click to hide internal directories.