Documentation ¶
Index ¶
- Variables
- func AuthKeyIDFromContext(ctx context.Context) uint64
- func ContextWithAuthKeyID(ctx context.Context, keyID uint64) context.Context
- func ContextWithMachineID(ctx context.Context, machineID string) context.Context
- func ContextWithUserID(ctx context.Context, userID uint64) context.Context
- func ExtractToken(raw string) (string, string, error)
- func ExtractTokenFromRequest(r *http.Request) (string, string, error)
- func Initialize(accessSecret, refreshSecret string, opts ...Option) error
- func MachineIDFromContext(ctx context.Context) string
- func NewLedisStore()
- func Shared() *jwt
- func UserIDFromContext(ctx context.Context) uint64
- func Valid(tokenStr string) (*stdjwt.Token, error)
- func VerifyToken(token string, accessSecret string) (*stdjwt.Token, error)
- type AccessDetails
- type Option
- type Store
- type TokenDetails
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound represents can not find the value with the key ErrNotFound = errors.New("not found") ErrUnauthorized = errors.New("unauthorized") // ErrTokenExpired represents the token is expired ErrTokenExpired = errors.New("token expired") // ErrIllegalParameter represents the input parameter(s) is illegal ErrIllegalParameter = errors.New("illegal parameter") // ErrInternalServerError represents the server do sth wrong ErrInternalServerError = errors.New("internal server error") )
Functions ¶
func AuthKeyIDFromContext ¶
AuthKeyIDFromContext returns the `auth key's id` previously associated with `ctx`,or `0` if no such `key id` could be found.
func ContextWithAuthKeyID ¶
ContextWithAuthKeyID returns a new `context.Context` that holds a auth key's id
func ContextWithMachineID ¶
ContextWithMachineID returns a new `context.Context` that holds a machine id
func ContextWithUserID ¶
ContextWithUserID returns a new `context.Context` that holds a uid
func ExtractToken ¶
ExtractToken extract the token from the raw string
func ExtractTokenFromRequest ¶
ExtractTokenFromRequest extract the token from http's Authorization header
func Initialize ¶
Initialize initialize the jwt
func MachineIDFromContext ¶
MachineIDFromContext returns the `machine id` previously associated with `ctx`, or `empty string if no such `machine id` could be found.
func NewLedisStore ¶
func NewLedisStore()
func UserIDFromContext ¶
UserIDFromContext returns the `uid` previously associated with `ctx`, or `0` if no such `uid` could be found.
Types ¶
type AccessDetails ¶
AccessDetails represents a helper object for manage jwt token
type Option ¶
type Option func(*options)
Option represents a handler for adjust the default option(s)
func AccessTokenTTL ¶
AccessTokenTTL adjust the access token's ttl in seconds
func RefreshTokenTTL ¶
RefreshTokenTTL adjust the refresh token's ttl in seconds