Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeKind ¶
NormalizeKind defaults empty kind to service_account.
func ValidateKindRules ¶
ValidateKindRules enforces personal vs service_account invariants.
Types ¶
type APIKey ¶
type APIKey struct {
ID string `json:"id"`
ProjectID string `json:"project_id,omitempty"`
OrganizationID string `json:"organization_id"`
EnvironmentID string `json:"environment_id,omitempty"`
Name string `json:"name"`
Kind string `json:"kind"`
OwnerUserID string `json:"owner_user_id,omitempty"`
KeyPrefix string `json:"key_prefix"`
Key string `json:"key,omitempty"` // plaintext only on create
CreatedAt time.Time `json:"created_at"`
}
APIKey is the write-model virtual API key.
func CreateAPIKey ¶
func CreateAPIKey( ctx context.Context, repo APIKeyRepository, projects ProjectOrgChecker, envs EnvironmentProjectChecker, id, orgID, kind, ownerUserID, projectID, environmentID, name, rawKey string, ) (*APIKey, error)
CreateAPIKey validates kind/project rules and persists the key.
type APIKeyRepository ¶
type APIKeyRepository interface {
ListByProject(ctx context.Context, projectID string) ([]APIKey, error)
ListByOrg(ctx context.Context, orgID string) ([]APIKey, error)
Get(ctx context.Context, keyID string) (*APIKey, error)
Insert(ctx context.Context, key APIKey, keyHash string) error
Delete(ctx context.Context, keyID string) error
OrgID(ctx context.Context, keyID string) (string, error)
}
APIKeyRepository persists write-model API keys.
type EnvironmentProjectChecker ¶
type EnvironmentProjectChecker interface {
EnvironmentBelongsToProject(ctx context.Context, environmentID, projectID, orgID string) error
}
EnvironmentProjectChecker verifies an environment belongs to a project in an org.
type KeyKind ¶
type KeyKind string
KeyKind is a typed API key kind.
const ( KeyKindPersonal KeyKind = snapshot.KeyKindPersonal KeyKindServiceAccount KeyKind = snapshot.KeyKindServiceAccount )
func ParseKeyKind ¶
ParseKeyKind validates and returns a KeyKind. Empty defaults to service_account.
func (KeyKind) IsPersonal ¶
IsPersonal reports whether the kind is personal.
Click to show internal directories.
Click to hide internal directories.