backend/pkg/permission/domain/entity/blacklist.go

34 lines
889 B
Go
Raw Normal View History

2025-10-06 08:28:39 +00:00
package entity
import "time"
// BlacklistEntry represents a blacklisted JWT token
type BlacklistEntry struct {
JTI string `json:"jti"` // JWT ID (unique identifier)
UID string `json:"uid"` // User ID
TokenID string `json:"token_id"` // Token ID from original token
Reason string `json:"reason"` // Reason for blacklisting
ExpiresAt int64 `json:"expires_at"` // When the original token expires
CreatedAt int64 `json:"created_at"` // When it was blacklisted
}
// IsExpired checks if the blacklist entry is expired
func (b *BlacklistEntry) IsExpired() bool {
return b.ExpiresAt <= time.Now().Unix()
}
// Validate validates the blacklist entry
func (b *BlacklistEntry) Validate() error {
if b.JTI == "" {
return ErrInvalidJTI
}
if b.UID == "" {
return ErrInvalidUID
}
if b.TokenID == "" {
return ErrInvalidTokenID
}
return nil
}