Documentation ¶
Overview ¶
Package tokens contains the models and functions to manage user API tokens.
Index ¶
Constants ¶
View Source
const (
// TableName is the user table name in database.
TableName = "token"
)
Variables ¶
View Source
var ( // Tokens is the token manager. Tokens = Manager{} // ErrNotFound is returned when a token record was not found. ErrNotFound = errors.New("not found") )
Functions ¶
func GetJwtClaims ¶
GetJwtClaims checks a raw JWT claims and returns it when it passes the signature validation.
func NewJwtToken ¶
NewJwtToken returns a new JWT token instance using a given ID and signing with the configuration's JWT secret key.
Types ¶
type Manager ¶
type Manager struct{}
Manager is a query helper for token entries.
func (*Manager) GetOne ¶
GetOne executes the a select query and returns the first result or an error when there's no result.
type Token ¶
type Token struct { ID int `db:"id" goqu:"skipinsert,skipupdate"` UID string `db:"uid"` UserID *int `db:"user_id"` Created time.Time `db:"created" goqu:"skipupdate"` Expires *time.Time `db:"expires"` IsEnabled bool `db:"is_enabled"` Application string `db:"application"` Roles types.Strings `db:"roles"` }
Token is a token record in database.
type TokenAndUser ¶
TokenAndUser is a result of a joint query on user and token tables.
Click to show internal directories.
Click to hide internal directories.