Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Token ¶
func Decode ¶
Decode parses a base64-encoded string into a Token instance. It validates the encoding and token format, ensuring data integrity. Accepts encoded which is a base64-encoded string containing token ID and Secret separated by a colon. Returns a Token containing the ID and Secret if decoding is successful. Returns an error if the base64 string is invalid or the token format is malformed.
func GenerateToken ¶
GenerateToken creates a new token with the specified keyID and time-to-live (TTL). It validates the keyID's length and characters, generating a random keyID if none is provided. Accepts keyID as the identifier for the token and ttl as the duration in seconds; if ttl is 0, a default value is used. Returns the generated Token structure or an error if validation fails, or if ID/secret generation errors occur.