Documentation
¶
Index ¶
- Constants
- Variables
- type AuthStore
- func (s *AuthStore) Blacklist(ctx context.Context, jti string, expiresAt time.Time) error
- func (s *AuthStore) DeleteExpiredTokens(ctx context.Context, now time.Time) error
- func (s *AuthStore) GenerateToken(actor mdk.Actor) (string, error)
- func (s *AuthStore) GetRefreshToken(ctx context.Context, token string) (*RefreshToken, error)
- func (s *AuthStore) IsBlacklisted(ctx context.Context, jti string) (bool, error)
- func (s *AuthStore) RevokeRefreshToken(ctx context.Context, token string) error
- func (s *AuthStore) SaveRefreshToken(ctx context.Context, t *RefreshToken) error
- func (s *AuthStore) ValidateToken(ctx context.Context, tokenString string) (mdk.Actor, error)
- type Blacklist
- type Claims
- type RefreshToken
Constants ¶
View Source
const (
PrefixBlacklist = "bl_"
)
Variables ¶
View Source
var (
ErrInvalidToken = errors.New("invalid token")
)
Functions ¶
This section is empty.
Types ¶
type AuthStore ¶
type AuthStore struct {
// contains filtered or unexported fields
}
AuthStore handles persistence for authentication tokens.
func NewAuthStore ¶
func (*AuthStore) DeleteExpiredTokens ¶
func (*AuthStore) GenerateToken ¶
GenerateToken creates a new JWT for an actor.
func (*AuthStore) GetRefreshToken ¶
func (*AuthStore) IsBlacklisted ¶
func (*AuthStore) RevokeRefreshToken ¶
func (*AuthStore) SaveRefreshToken ¶
func (s *AuthStore) SaveRefreshToken(ctx context.Context, t *RefreshToken) error
type Blacklist ¶
type Blacklist struct {
ID string `gorm:"primaryKey"`
JTI string `gorm:"uniqueIndex;not null"`
ExpiresAt time.Time `gorm:"index;not null"`
}
Blacklist tracks revoked JWT IDs.
type Claims ¶
type Claims struct {
ActorID string `json:"actor_id"`
ActorType mdk.ActorType `json:"actor_type"`
jwt.RegisteredClaims
}
Claims represents the JWT actor payload claims.
type RefreshToken ¶
type RefreshToken struct {
ID string `gorm:"primaryKey"`
ActorID string `gorm:"index;not null"`
Token string `gorm:"uniqueIndex;not null"`
ExpiresAt time.Time `gorm:"not null"`
RevokedAt *time.Time
CreatedAt time.Time
}
RefreshToken represents a long-lived token used to generate new JWTs.
Click to show internal directories.
Click to hide internal directories.