Documentation
¶
Overview ¶
Package apikeystore persists the database-managed API keys the platform loads alongside the keys declared in configuration.
It is a facade-internal seam: pkg/platform constructs it and hands the resulting Store to the admin API through its own accessor, so the store has exactly two first-party callers and no business living on the module's supported import surface (docs/library/stability.md). pkg/platform keeps aliases for the two types the admin handler names, so the facade's published contract is unchanged by the move.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("api key not found")
ErrNotFound is returned when an API key does not exist in the database.
Functions ¶
This section is empty.
Types ¶
type Definition ¶
type Definition struct {
Name string `json:"name"`
KeyHash string `json:"key_hash"`
Email string `json:"email,omitempty"`
Description string `json:"description,omitempty"`
Roles []string `json:"roles"`
ExpiresAt *time.Time `json:"expires_at,omitempty"`
CreatedBy string `json:"created_by"`
CreatedAt time.Time `json:"created_at"`
}
Definition represents a database-managed API key.
type NoopStore ¶
type NoopStore struct{}
NoopStore is a no-op implementation for when no database is available.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore implements Store backed by PostgreSQL.
func NewPostgres ¶
func NewPostgres(db *sql.DB) *PostgresStore
NewPostgres creates a new PostgreSQL-backed API key store.
func (*PostgresStore) Delete ¶
func (s *PostgresStore) Delete(ctx context.Context, name string) error
Delete removes an API key definition by name.
func (*PostgresStore) List ¶
func (s *PostgresStore) List(ctx context.Context) ([]Definition, error)
List returns all API key definitions.
func (*PostgresStore) Set ¶
func (s *PostgresStore) Set(ctx context.Context, def Definition) error
Set creates or updates an API key definition.