Documentation
¶
Index ¶
- Variables
- func ContextWithToken(ctx context.Context, token *apiv2.Token) context.Context
- func NewJWT(tokenType apiv2.TokenType, subject, issuer string, expires time.Duration, ...) (string, *apiv2.Token, error)
- func TokenFromContext(ctx context.Context) (*apiv2.Token, bool)
- type Claims
- type TokenStore
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultExpiration = time.Hour * 8 MaxExpiration = 365 * 24 * time.Hour )
View Source
var (
ErrTokenNotFound = redis.Nil
)
Functions ¶
func ContextWithToken ¶
ContextWithToken stores the token in the Context Can later retrieved with TokenFromContext
Types ¶
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
Type string `json:"type"`
}
func ParseJWTToken ¶
ParseJWTToken unverified to Claims to get Issuer,Subject, Roles and Permissions
type TokenStore ¶
type TokenStore interface {
Set(ctx context.Context, token *apiv2.Token) error
Get(ctx context.Context, userid, tokenid string) (*apiv2.Token, error)
List(ctx context.Context, userid string) ([]*apiv2.Token, error)
AdminList(ctx context.Context) ([]*apiv2.Token, error)
Revoke(ctx context.Context, userid, tokenid string) error
Migrate(ctx context.Context, log *slog.Logger) error
}
func NewRedisStore ¶
func NewRedisStore(client *redis.Client) TokenStore
Click to show internal directories.
Click to hide internal directories.