Documentation ¶
Index ¶
Constants ¶
View Source
const ( JWS TokenType = "jws" JWE TokenType = "jwe" // JWS HS256 AlgorithmType = "HS256" RS256 AlgorithmType = "RS256" None AlgorithmType = "none" // JWE RSA_OAEP AlgorithmType = "RSA-OAEP" A256GCM AuthAlgorithmType = "A256GCM" )
Variables ¶
View Source
var ( // JWS JwsAlgorithmsMap = map[AlgorithmType]bool{ HS256: true, RS256: true, None: true, } // JWE JweAlgorithmsMap = map[AlgorithmType]bool{ RSA_OAEP: true, } JweAuthAlgorithmsMap = map[AuthAlgorithmType]bool{ A256GCM: true, } JweAuthAlgorithmSizeMap = map[AuthAlgorithmType]int{ A256GCM: 32, } )
Functions ¶
This section is empty.
Types ¶
type AlgorithmSuite ¶
type AlgorithmSuite struct { AlgorithmType AuthAlgorithmType }
type AlgorithmType ¶
type AlgorithmType string
type AuthAlgorithmType ¶
type AuthAlgorithmType string
type ClaimSet ¶
type ClaimSet map[string]interface{}
func NewClaimSet ¶
func NewClaimSet() ClaimSet
func (*ClaimSet) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (*ClaimSet) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
type Header ¶
func (*Header) Deserialize ¶ added in v0.6.0
func (*Header) GetAlgorithm ¶
func (h *Header) GetAlgorithm() (AlgorithmType, error)
func (*Header) GetEncryptionAlgorithm ¶ added in v0.6.0
func (h *Header) GetEncryptionAlgorithm() (AuthAlgorithmType, error)
type Payload ¶
func (*Payload) Deserialize ¶ added in v0.6.0
type RegisteredClaim ¶
type RegisteredClaim string
const ( Issuer RegisteredClaim = "iss" Subject RegisteredClaim = "sub" Audience RegisteredClaim = "aud" ExpirationTime RegisteredClaim = "exp" NotBefore RegisteredClaim = "nbf" IssuedAt RegisteredClaim = "iat" JwtID RegisteredClaim = "jti" )
type Token ¶
type Token struct { TokenType TokenType TokenInstance TokenInstance Claims map[string]interface{} Metadata *Metadata }
type TokenInstance ¶
type TokenInstance interface { // Encode generates a serialized representation of the token, typically in a compact format like JWE or JWT. // It returns the encoded token as a byte slice and any potential errors encountered during encoding. Encode() (string, error) // Decode parses a serialized token (split into its parts) and populates the internal token structure. // For JWS, the header, payload, SignFunc and ValidateFunc are all populated (along with Metadata byte values). // For JWE, the header, encryptedKey, initialization vector, cipher text, SignFunc and Validate func are // all populated (along with Metadata byte values). // It takes the token parts as input and returns an error if the decoding or parsing process fails. Decode(parts []string) error // Validate verifies the integrity and authenticity of the token, checking signatures, claims, and expiration if applicable. // Uniquely for JWE, it is only after the call to Validate that the payload data is populated into the token struct. This is // because the payload is not available when calling Decode like it is for a JWS. It is only after Validating the token that // the 'cipher text' is decrypted to reveal the contents of the payload (which can be JSON, or any other data). // It returns a boolean indicating whether the token is valid and any potential errors encountered during validation. Validate() (bool, error) }
TokenInstance represents an interface for working with tokens. TokenInstance will either be an instance of a JWE or JWS token.
Click to show internal directories.
Click to hide internal directories.