README ¶ Token Installation Use go get. go get github.com/go-funcards/token Then import token package into your own code. import "github.com/go-funcards/token" License Distributed under MIT License, please see license file within the code for more details. Expand ▾ Collapse ▴ Documentation ¶ Index ¶ func New(cfg Config, generator jwt.Generator, storage Storage) *service type Config type Service type Session type Storage Constants ¶ This section is empty. Variables ¶ This section is empty. Functions ¶ func New ¶ func New(cfg Config, generator jwt.Generator, storage Storage) *service Types ¶ type Config ¶ type Config struct { TokenType string `mapstructure:"token_type" yaml:"token_type" env:"TOKEN_TYPE" env-default:"Bearer"` TTL time.Duration `mapstructure:"ttl" yaml:"ttl" env:"TTL" env-default:"8760h"` } type Service ¶ type Service interface { SessByRefreshToken(ctx context.Context, refreshToken string) (Session, error) SessByUser(ctx context.Context, user jwt.User) (Session, error) } type Session ¶ type Session struct { TokenType string `json:"token_type"` // Bearer ExpiresIn uint `json:"expires_in"` // The lifetime in seconds of refresh token AccessToken string `json:"access_token"` RefreshToken string `json:"refresh_token"` } type Storage ¶ type Storage interface { Set(ctx context.Context, refreshToken string, user jwt.User, expiration time.Duration) error Get(ctx context.Context, refreshToken string) (jwt.User, error) Del(ctx context.Context, refreshToken string) } Source Files ¶ View all Source files service.gosession.gostorage.go Click to show internal directories. Click to hide internal directories.