Documentation
¶
Index ¶
- Variables
- type APIKey
- func (k *APIKey) CreatedAt() time.Time
- func (k *APIKey) CreatedBy() *ID
- func (k *APIKey) Description() string
- func (k *APIKey) ExpiresAt() *time.Time
- func (k *APIKey) ID() ID
- func (k *APIKey) IsActive() bool
- func (k *APIKey) KeyHash() string
- func (k *APIKey) KeyPrefix() string
- func (k *APIKey) LastUsedAt() *time.Time
- func (k *APIKey) LastUsedIP() string
- func (k *APIKey) Name() string
- func (k *APIKey) RateLimit() int
- func (k *APIKey) Revoke(revokedBy ID) error
- func (k *APIKey) RevokedAt() *time.Time
- func (k *APIKey) RevokedBy() *ID
- func (k *APIKey) Scopes() []string
- func (k *APIKey) SetCreatedBy(id ID)
- func (k *APIKey) SetDescription(desc string)
- func (k *APIKey) SetExpiresAt(t *time.Time)
- func (k *APIKey) SetRateLimit(limit int)
- func (k *APIKey) SetScopes(scopes []string)
- func (k *APIKey) SetUserID(id *ID)
- func (k *APIKey) Status() Status
- func (k *APIKey) TenantID() ID
- func (k *APIKey) UpdatedAt() time.Time
- func (k *APIKey) UseCount() int64
- func (k *APIKey) UserID() *ID
- type Filter
- type ID
- type ListResult
- type Repository
- type Status
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrAPIKeyNotFound = fmt.Errorf("%w: api key not found", shared.ErrNotFound) ErrAPIKeyNameExists = fmt.Errorf("%w: api key name already exists", shared.ErrAlreadyExists) )
Functions ¶
This section is empty.
Types ¶
type APIKey ¶
type APIKey struct {
// contains filtered or unexported fields
}
APIKey represents a tenant API key for programmatic access.
func Reconstruct ¶
func Reconstruct( id, tenantID ID, userID *ID, name, description, keyHash, keyPrefix string, scopes []string, rateLimit int, status Status, expiresAt, lastUsedAt *time.Time, lastUsedIP string, useCount int64, createdBy *ID, createdAt, updatedAt time.Time, revokedAt *time.Time, revokedBy *ID, ) *APIKey
Reconstruct creates an APIKey from stored data (database reconstruction).
func (*APIKey) Description ¶
func (*APIKey) LastUsedAt ¶
func (*APIKey) LastUsedIP ¶
func (*APIKey) SetCreatedBy ¶
func (*APIKey) SetDescription ¶
func (*APIKey) SetExpiresAt ¶
func (*APIKey) SetRateLimit ¶
type Filter ¶
type Filter struct {
TenantID *ID
UserID *ID
Status *Status
Search string
Page int
PerPage int
SortBy string
SortOrder string
}
Filter represents filtering options for listing API keys.
type ListResult ¶
ListResult represents a paginated list of API keys.
type Repository ¶
type Repository interface {
Create(ctx context.Context, key *APIKey) error
GetByID(ctx context.Context, id, tenantID ID) (*APIKey, error)
GetByHash(ctx context.Context, hash string) (*APIKey, error)
List(ctx context.Context, filter Filter) (ListResult, error)
Update(ctx context.Context, key *APIKey) error
Delete(ctx context.Context, id, tenantID ID) error
}
Repository defines the interface for API key persistence.
Click to show internal directories.
Click to hide internal directories.