Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TokenBuilder ¶ added in v0.6.0
type TokenBuilder struct {
// contains filtered or unexported fields
}
func DecodeToken ¶ added in v0.6.0
func DecodeToken(tokenString string, key []byte) (*TokenBuilder, error)
DecodeToken decodes a token string using the provided key and returns a TokenBuilder.
Parameters:
- tokenString: The string representation of the token to be decoded.
- key: The key (byte slice) used for decoding the token.
Returns:
- A pointer to a TokenBuilder containing the decoded token information and algorithm suite.
- An error if there's an issue decoding the token or extracting algorithm details.
This function performs the following steps: 1. Decodes the token string using the `decodeToken` helper function and the provided key. 2. Creates a new TokenBuilder and sets its `token` field to the decoded token. 3. Switches on the token type:
- If JWE (JSON Web Encryption):
- Extracts the algorithm and encryption algorithm from the token header.
- Sets the TokenBuilder's `algSuite` with the extracted algorithms.
- If JWS (JSON Web Signature):
- Extracts the algorithm from the token header.
- Sets the TokenBuilder's `algSuite` with the extracted algorithm. 4. Returns the TokenBuilder and a nil error if successful, or a nil TokenBuilder and the corresponding error if there was an issue during decoding or algorithm extraction.
func NewJWEToken ¶ added in v0.6.0
func NewJWEToken(suite common.AlgorithmSuite, key []byte) *TokenBuilder
func NewJWSToken ¶ added in v0.6.0
func NewJWSToken(algorithmType common.AlgorithmType, key []byte) *TokenBuilder
func (*TokenBuilder) AddClaims ¶ added in v0.6.0
func (b *TokenBuilder) AddClaims(claims common.ClaimSet) *TokenBuilder
func (*TokenBuilder) GetClaims ¶ added in v0.6.0
func (b *TokenBuilder) GetClaims() common.ClaimSet
func (*TokenBuilder) Serialize ¶ added in v0.6.0
func (b *TokenBuilder) Serialize() (string, error)
func (*TokenBuilder) Validate ¶ added in v0.6.0
func (b *TokenBuilder) Validate() (bool, error)
Click to show internal directories.
Click to hide internal directories.