Documentation
¶
Index ¶
- Variables
- type Provider
- type Session
- func (s *Session) Claims() *jwt.Claims
- func (s *Session) Del(ctx context.Context, key string) error
- func (s *Session) Destroy(ctx context.Context) error
- func (s *Session) Get(ctx context.Context, key string) (any, error)
- func (s *Session) Refresh(ctx context.Context) error
- func (s *Session) Set(ctx context.Context, key string, val any) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSessionNotFound = errors.New("session not found") ErrSessionExpired = errors.New("session expired") )
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider 内存 Session Provider 注意:仅用于开发测试,生产环境请使用 Redis
func NewProvider ¶
func NewProvider(jwtKey string, accessExpire, refreshExpire time.Duration, carrier session.TokenCarrier) *Provider
NewProvider 创建内存 Session Provider jwtKey: JWT 签名密钥 accessExpire: Access Token 过期时间(建议 15 分钟 - 2 小时) refreshExpire: Refresh Token 过期时间(建议 7 天 - 30 天) carrier: Token 载体(Header 或 Cookie)
Click to show internal directories.
Click to hide internal directories.