Documentation ¶
Index ¶
- func CreateAccessToken(p *mjwt.Issuer, sub, id string, aud jwt.ClaimStrings, perms *PermStorage) (string, error)
- func CreateAccessTokenWithDuration(p *mjwt.Issuer, dur time.Duration, sub, id string, aud jwt.ClaimStrings, ...) (string, error)
- func CreateRefreshToken(p *mjwt.Issuer, sub, id, ati string, aud jwt.ClaimStrings) (string, error)
- func CreateRefreshTokenWithDuration(p *mjwt.Issuer, dur time.Duration, sub, id, ati string, aud jwt.ClaimStrings) (string, error)
- func CreateTokenPair(p *mjwt.Issuer, sub, id, rId string, aud, rAud jwt.ClaimStrings, ...) (string, string, error)
- func CreateTokenPairWithDuration(p *mjwt.Issuer, accessDur, refreshDur time.Duration, sub, id, rId string, ...) (string, string, error)
- type AccessTokenClaims
- type PermStorage
- func (p *PermStorage) Clear(perm string)
- func (p *PermStorage) Dump() []string
- func (p *PermStorage) Filter(match []string) *PermStorage
- func (p *PermStorage) Has(perm string) bool
- func (p *PermStorage) MarshalJSON() ([]byte, error)
- func (p *PermStorage) MarshalYAML() (interface{}, error)
- func (p *PermStorage) OneOf(o *PermStorage) bool
- func (p *PermStorage) Search(v string) []string
- func (p *PermStorage) Set(perm string)
- func (p *PermStorage) UnmarshalJSON(bytes []byte) error
- func (p *PermStorage) UnmarshalYAML(value *yaml.Node) error
- type RefreshTokenClaims
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAccessToken ¶
func CreateAccessToken(p *mjwt.Issuer, sub, id string, aud jwt.ClaimStrings, perms *PermStorage) (string, error)
CreateAccessToken creates an access token with the default 15 minute duration
func CreateAccessTokenWithDuration ¶
func CreateAccessTokenWithDuration(p *mjwt.Issuer, dur time.Duration, sub, id string, aud jwt.ClaimStrings, perms *PermStorage) (string, error)
CreateAccessTokenWithDuration creates an access token with a custom duration
func CreateRefreshToken ¶
CreateRefreshToken creates a refresh token with the default 7 day duration
func CreateRefreshTokenWithDuration ¶
func CreateRefreshTokenWithDuration(p *mjwt.Issuer, dur time.Duration, sub, id, ati string, aud jwt.ClaimStrings) (string, error)
CreateRefreshTokenWithDuration creates a refresh token with a custom duration
func CreateTokenPair ¶
func CreateTokenPair(p *mjwt.Issuer, sub, id, rId string, aud, rAud jwt.ClaimStrings, perms *PermStorage) (string, string, error)
CreateTokenPair creates an access and refresh token pair using the default 15 minute and 7 day durations respectively
func CreateTokenPairWithDuration ¶
func CreateTokenPairWithDuration(p *mjwt.Issuer, accessDur, refreshDur time.Duration, sub, id, rId string, aud, rAud jwt.ClaimStrings, perms *PermStorage) (string, string, error)
CreateTokenPairWithDuration creates an access and refresh token pair using custom durations for the access and refresh tokens
Types ¶
type AccessTokenClaims ¶
type AccessTokenClaims struct {
Perms *PermStorage `json:"per"`
}
AccessTokenClaims contains the JWT claims for an access token
func (AccessTokenClaims) Type ¶
func (a AccessTokenClaims) Type() string
func (AccessTokenClaims) Valid ¶
func (a AccessTokenClaims) Valid() error
type PermStorage ¶ added in v0.4.0
type PermStorage struct {
// contains filtered or unexported fields
}
func NewPermStorage ¶ added in v0.4.0
func NewPermStorage() *PermStorage
func ParsePermStorage ¶ added in v0.4.0
func ParsePermStorage(perms string) *PermStorage
func (*PermStorage) Clear ¶ added in v0.4.0
func (p *PermStorage) Clear(perm string)
func (*PermStorage) Dump ¶ added in v0.4.0
func (p *PermStorage) Dump() []string
func (*PermStorage) Filter ¶ added in v0.4.0
func (p *PermStorage) Filter(match []string) *PermStorage
func (*PermStorage) Has ¶ added in v0.4.0
func (p *PermStorage) Has(perm string) bool
func (*PermStorage) MarshalJSON ¶ added in v0.4.0
func (p *PermStorage) MarshalJSON() ([]byte, error)
func (*PermStorage) MarshalYAML ¶ added in v0.4.0
func (p *PermStorage) MarshalYAML() (interface{}, error)
func (*PermStorage) OneOf ¶ added in v0.4.0
func (p *PermStorage) OneOf(o *PermStorage) bool
func (*PermStorage) Search ¶ added in v0.4.0
func (p *PermStorage) Search(v string) []string
func (*PermStorage) Set ¶ added in v0.4.0
func (p *PermStorage) Set(perm string)
func (*PermStorage) UnmarshalJSON ¶ added in v0.4.0
func (p *PermStorage) UnmarshalJSON(bytes []byte) error
func (*PermStorage) UnmarshalYAML ¶ added in v0.4.0
func (p *PermStorage) UnmarshalYAML(value *yaml.Node) error
type RefreshTokenClaims ¶
type RefreshTokenClaims struct {
AccessTokenId string `json:"ati"`
}
RefreshTokenClaims contains the JWT claims for a refresh token AccessTokenId (ati) must match the similar JWT ID (jti) claim
func (RefreshTokenClaims) Type ¶
func (r RefreshTokenClaims) Type() string
func (RefreshTokenClaims) Valid ¶
func (r RefreshTokenClaims) Valid() error