Documentation ¶
Index ¶
Constants ¶
View Source
const ( // Version used for creating token Version = 0 // TokenSep used as a delimiter for the token TokenSep = "." // MaxUIDLen is the maximum length for an UID MaxUIDLen = 256 )
View Source
const ( TokenAlgorithm = "HS256" TokenType = "JWT" )
Firebase specific values for header
Variables ¶
View Source
var ( ErrNoUIDKey = errors.New(`Data payload must contain a "uid" key`) ErrUIDNotString = errors.New(`Data payload key "uid" must be a string`) ErrUIDTooLong = errors.New(`Data payload key "uid" must not be longer than 256 characters`) ErrEmptyDataNoOptions = errors.New("Data is empty and no options are set. This token will have no effect on Firebase.") ErrTokenTooLong = errors.New("Generated token is too long. The token cannot be longer than 1024 bytes.") )
Generic errors
Functions ¶
Types ¶
type Data ¶
type Data map[string]interface{}
Data is used to create a token. The token data can contain any data of your choosing, however it must contain a `uid` key, which must be a string of less than 256 characters
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator represents a token generator
type Option ¶
type Option struct { // NotBefote is the token "not before" date as a number of seconds since the Unix epoch. // If specified, the token will not be considered valid until after this date. NotBefore int64 `json:"nbf,omitempty"` // Expiration is the token expiration date as a number of seconds since the Unix epoch. // If not specified, by default the token will expire 24 hours after the "issued at" date (iat). Expiration int64 `json:"exp,omitempty"` // Admin when set to true to make this an "admin" token, which grants full read and // write access to all data. Admin bool `json:"admin,omitempty"` // Debug when set to true to enable debug mode, which provides verbose error messages // when Security and Firebase Rules fail. Debug bool `json:"debug,omitempty"` }
Option represent the claims used when creating an authentication token https://www.firebase.com/docs/rest/guide/user-auth.html#section-rest-tokens-without-helpers
Click to show internal directories.
Click to hide internal directories.