Documentation
¶
Index ¶
- Constants
- Variables
- func IsAccess(claims Claims) bool
- func IsApi(claims Claims) bool
- func IsCustomer(claims Claims) bool
- func IsReference(claims Claims) bool
- func IsRefresh(claims Claims) bool
- func Query(db *datastore.Datastore) datastore.Query
- type AccessClaims
- type Claims
- type Token
- func (t *Token) Decode(str string, secret []byte) error
- func (t *Token) Defaults()
- func (t *Token) Encode(secret []byte) (string, error)
- func (t *Token) IsValid(nowUnix int64) error
- func (t *Token) IssueAccessToken(usrId string, secret []byte) (string, error)
- func (t *Token) IssueRefreshToken(usrId string, secret []byte) (string, error)
- func (t *Token) Load(properties []datastore.Property) error
- func (t *Token) Revoke()
- func (t *Token) Save() ([]datastore.Property, error)
- type Type
Constants ¶
View Source
const ( // Internal Claims used to store Access Token claims Reference Type = "reference" // Special Username/Password OAuth grant key Api = "api" // Claims generated by Reference Claims Access = "access" // Customer is a Special Access Token generated from API Claim Customer = "customer" // Token issued using the Reference Claims, used only to request new Acess Claims Refresh = "refresh" )
View Source
const (
Algorithm = "HS256"
)
Variables ¶
View Source
var ( InvalidTokenType = errors.New("Invalid token type") TokenOwnershipInvalid = errors.New("Token does not belong to this user") TokenRevoked = errors.New("Token is revoked") TokenIsExpired = jwt.TokenIsExpired TokenIsNotValidYet = jwt.TokenIsNotValidYet )
Functions ¶
func IsCustomer ¶
Types ¶
type AccessClaims ¶
type Claims ¶
type Claims struct {
jwt.Claims
AccessClaims
AppId string `json:"app,omitempty"`
UserId string `json:"usr,omitempty"`
OrganizationName string `json:"org,omitempty"`
Type Type `json:"typ,omitempty"`
Scopes []string `json:"scopes,omitempty"`
Test bool `json:"tst,omitempty"`
Permissions bit.Field `json:"bit,omitempty"`
}
Used for Refresh and Site Tokens
type Token ¶
type Token struct {
mixin.Model[Token]
Claims Claims `json:"claims"`
Name string `json:"name"`
// In Hours
AccessPeriod int64 `json:"accessPeriod"`
Revoked bool `json:"revoked"`
String string `json:"-" datastore:",noindex"`
}
func (*Token) IssueAccessToken ¶
Issues short term expiration token for site/cli/dashboard
func (*Token) IssueRefreshToken ¶
Click to show internal directories.
Click to hide internal directories.