Documentation
¶
Index ¶
- type Record
- type Repository
- func (r *Repository) CreateToken(ctx context.Context, token types.UserToken) (*types.UserToken, error)
- func (r *Repository) GetTokenByJTI(ctx context.Context, tokenType types.UserTokenType, jti string) (*types.UserToken, error)
- func (r *Repository) UpdateTokenStatus(ctx context.Context, tokenType types.UserTokenType, jti string, ...) error
- type RepositoryConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Record ¶
type Record struct {
bun.BaseModel `bun:"table:user_tokens"`
ID uuid.UUID `bun:"id,pk,type:uuid"`
UserID uuid.UUID `bun:"user_id,notnull,type:uuid"`
TokenType string `bun:"token_type,notnull"`
JTI string `bun:"jti,notnull"`
Status string `bun:"status,notnull"`
IssuedAt *time.Time `bun:"issued_at,nullzero"`
ExpiresAt *time.Time `bun:"expires_at,nullzero"`
UsedAt *time.Time `bun:"used_at,nullzero"`
CreatedAt time.Time `bun:"created_at"`
UpdatedAt time.Time `bun:"updated_at"`
}
Record models the persisted user_tokens row.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repository implements types.UserTokenRepository using Bun.
func NewRepository ¶
func NewRepository(cfg RepositoryConfig) (*Repository, error)
NewRepository constructs the default token repository.
func (*Repository) CreateToken ¶
func (r *Repository) CreateToken(ctx context.Context, token types.UserToken) (*types.UserToken, error)
CreateToken persists a user token record.
func (*Repository) GetTokenByJTI ¶
func (r *Repository) GetTokenByJTI(ctx context.Context, tokenType types.UserTokenType, jti string) (*types.UserToken, error)
GetTokenByJTI returns the token record matching the JTI and type.
func (*Repository) UpdateTokenStatus ¶
func (r *Repository) UpdateTokenStatus(ctx context.Context, tokenType types.UserTokenType, jti string, status types.UserTokenStatus, usedAt time.Time) error
UpdateTokenStatus updates the token status and usage timestamp.
type RepositoryConfig ¶
type RepositoryConfig struct {
DB *bun.DB
Repository repository.Repository[*Record]
Clock types.Clock
}
RepositoryConfig wires the Bun-backed token repository.
Click to show internal directories.
Click to hide internal directories.