Documentation
¶
Index ¶
- Constants
- Variables
- func ApidPrefixToLabelToken(p apid.Prefix) string
- func BuildLabelSelectorFromMap(labels map[string]string) string
- func IsValidActorOrderByField[T string | ActorOrderByField](field T) bool
- func IsValidConnectionHealthState[T string | ConnectionHealthState](state T) bool
- func IsValidConnectionOrderByField[T string | ConnectionOrderByField](field T) bool
- func IsValidConnectionState[T string | ConnectionState](state T) bool
- func IsValidConnectorDefinitionVersionOrderByField[T string | ConnectorDefinitionVersionOrderByField](field T) bool
- func IsValidConnectorDefinitionVersionState[T string | ConnectorDefinitionVersionState](state T) bool
- func IsValidConnectorOrderByField[T string | ConnectorOrderByField](field T) bool
- func IsValidKeyMaterialType[T string | KeyMaterialType](materialType T) bool
- func IsValidKeyOrderByField[T string | KeyOrderByField](field T) bool
- func IsValidKeyState[T string | KeyState](state T) bool
- func IsValidKeyUsage[T string | KeyUsage](usage T) bool
- func IsValidNamespaceOrderByField[T string | NamespaceOrderByField](field T) bool
- func IsValidNamespaceState[T string | NamespaceState](state T) bool
- func IsValidNotificationLevel[T string | NotificationLevel](level T) bool
- func IsValidNotificationState[T string | NotificationState](state T) bool
- func IsValidRateLimitOrderByField[T string | RateLimitOrderByField](field T) bool
- func IsValidSearchResourceType(t SearchResourceType) bool
- func RegisterEncryptedField(reg EncryptedFieldRegistration)
- func ValidateAnnotationKey(key string) error
- func ValidateAnnotationValue(_ string) error
- func ValidateAnnotations(annotations map[string]string) error
- func ValidateApxyLabelValue(value string) error
- func ValidateLabelKey(key string) error
- func ValidateLabelValue(value string) error
- func ValidateLabels(labels map[string]string) error
- func ValidateUserLabelDeletionKeys(keys []string) error
- func ValidateUserLabelKey(key string) error
- func ValidateUserLabels(labels map[string]string) error
- type Actor
- func (a *Actor) CanSelfSign() bool
- func (a *Actor) GetAnnotations() map[string]string
- func (a *Actor) GetEncryptedKey() *encfield.EncryptedField
- func (a *Actor) GetExternalId() string
- func (a *Actor) GetId() apid.ID
- func (a *Actor) GetLabels() map[string]string
- func (a *Actor) GetName() scommon.ResourceName
- func (a *Actor) GetNamespace() string
- func (a *Actor) GetPermissions() []aschema.Permission
- type ActorOrderByField
- type Annotations
- type ApiKeyCredential
- type ApiKeyCredentialPlaintext
- type Connection
- func (c *Connection) GetAnnotations() map[string]string
- func (c *Connection) GetConnectorId() apid.ID
- func (c *Connection) GetConnectorVersion() uint64
- func (c *Connection) GetId() apid.ID
- func (c *Connection) GetLabels() map[string]string
- func (c *Connection) GetNamespace() string
- func (c *Connection) Validate() error
- type ConnectionHealthState
- type ConnectionOrderByField
- type ConnectionProbeOutcome
- type ConnectionState
- type ConnectionVersionMigrationUpdate
- type Connector
- type ConnectorDefinitionVersion
- type ConnectorDefinitionVersionId
- type ConnectorDefinitionVersionOrderByField
- type ConnectorDefinitionVersionState
- type ConnectorOrderByField
- type ConnectorWithDefinition
- type DB
- type DataEncryptionKey
- type DataEncryptionKeyProviderMetadata
- type DeletedHandling
- type EncryptedFieldRegistration
- type IActorData
- type IActorDataExtended
- type Key
- type KeyMaterialType
- type KeyOrderByField
- type KeyState
- type KeyUsage
- type LabelOperator
- type LabelRequirement
- type LabelSelector
- type Labels
- func ApplyParentCarryForward(userLabels Labels, parents ...ParentCarryForward) Labels
- func BuildCarriedLabels(parentRt string, parentLabels Labels) Labels
- func BuildImplicitResourceLabels(id apid.ID, name scommon.ResourceName, namespacePath string) Labels
- func BuildImplicitResourceLabelsForToken(rt, id string, name scommon.ResourceName, namespacePath string) Labels
- func BuildNamespaceImplicitResourceLabels(path string) Labels
- func InjectNamespaceSelfImplicitLabels(path string, existing Labels) Labels
- func InjectSelfImplicitLabels(id apid.ID, name scommon.ResourceName, namespacePath string, existing Labels) Labels
- func MergeApxyAndUserLabels(user, apxy Labels) Labels
- func MergeUpsertLabels(callerLabels, existingLabels Labels) Labels
- func SplitUserAndApxyLabels(labels Labels) (user, apxy Labels)
- type ListActorsBuilder
- type ListActorsExecutor
- type ListConnectionsBuilder
- type ListConnectionsExecutor
- type ListConnectorDefinitionVersionsBuilder
- type ListConnectorDefinitionVersionsExecutor
- type ListConnectorsBuilder
- type ListConnectorsExecutor
- type ListKeysBuilder
- type ListKeysExecutor
- type ListNamespacesBuilder
- type ListNamespacesExecutor
- type ListNotificationsOptions
- type ListRateLimitsBuilder
- type ListRateLimitsExecutor
- type Namespace
- type NamespaceEncryptionTarget
- type NamespaceOrderByField
- type NamespaceState
- type NamespaceTargetDataEncryptionKeyUpdate
- type Notification
- type NotificationLevel
- type NotificationMetadata
- type NotificationPermissions
- type NotificationState
- type NotificationUpsert
- type OAuth2ClientCredentialsPlaintext
- type OAuth2Token
- type OAuth2TokenWithConnection
- type ParentCarryForward
- type Permissions
- type RateLimit
- type RateLimitOrderByField
- type ReEncryptedFieldUpdate
- type ReEncryptionTarget
- type ResourceSearcher
- type SearchLabelMatch
- type SearchResource
- type SearchResourceType
- type SearchResourcesParams
- type SearchResourcesResult
- type UsedNonce
Constants ¶
const ( ProbeOutcomeStatusSuccess = "success" ProbeOutcomeStatusFailure = "failure" )
Outcome enum stored in connection_probe_outcomes.outcome.
const ( // LabelKeyNameMaxLength is the maximum length for the name portion of a label key LabelKeyNameMaxLength = 63 // LabelKeyPrefixMaxLength is the maximum length for the optional prefix portion of a label key LabelKeyPrefixMaxLength = 253 // LabelValueMaxLength is the maximum length for a label value LabelValueMaxLength = 63 // ApxyLabelValueMaxLength is the maximum length for a label value stored // under an apxy/-prefixed key. System-managed labels such as // apxy/<rt>/-/ns can hold a namespace path that may exceed the standard // LabelValueMaxLength. User-supplied values are still capped at // LabelValueMaxLength via ValidateLabelValue. ApxyLabelValueMaxLength = 253 // ApxyReservedPrefix is the reserved label-key prefix for system-managed // labels (implicit identifier labels and parent carry-forward labels). // User-supplied label keys may not begin with this prefix. ApxyReservedPrefix = "apxy/" // ApxyImplicitSegment is the segment used inside apxy/ keys to mark an // implicit identifier label, e.g. apxy/<rt>/-/id. ApxyImplicitSegment = "-" )
Kubernetes-style label restrictions
const ( // NotificationKeyAuthRequired is the condition key suffix used when a // connection requires the actor to re-authenticate, e.g. // "connection:cxn_...:auth_required". NotificationKeyAuthRequired = "auth_required" // NotificationKeySetupRequired is the condition key suffix used when a // connection requires additional setup, e.g. // "connection:cxn_...:setup_required". NotificationKeySetupRequired = "setup_required" )
const ( NotificationsTable = "notifications" NotificationViewsTable = "notification_views" )
const ActorTable = "actors"
const ( // AnnotationsTotalMaxSize is the maximum total size of all annotations (keys + values) in bytes. AnnotationsTotalMaxSize = 256 * 1024 // 256KB )
const ConnectionCredentialsTable = "connection_credentials"
const ConnectionProbeOutcomesTable = "connection_probe_outcomes"
const ConnectionsTable = "connections"
const ConnectorDefinitionVersionsTable = "connector_definition_versions"
const ConnectorsTable = "connectors"
const DataEncryptionKeysTable = "data_encryption_keys"
const KeysTable = "keys"
const MigrateMutexKeyName = "db-migrate-lock"
MigrateMutexKeyName is the key that can be used when locking to perform a migration in redis.
const NamespaceLabelToken = "ns"
NamespaceLabelToken is the <rt> token used in apxy/ keys that reference a namespace. Namespaces are path-keyed (not apid-keyed) so the token is hard-coded rather than derived from an apid prefix.
const NamespacesTable = "namespaces"
const OAuth2AccessTokenExpiryBuffer = 30 * time.Second
const OAuth2TokensTable = "oauth2_tokens"
const RateLimitsTable = "rate_limits"
const UsedNoncesTable = "used_nonces"
Variables ¶
var ErrDuplicate = errors.New("duplicate record")
ErrDuplicate is returned when a database operation that is expected to be unique fails because a duplicate record already exists.
var ErrNamespaceDoesNotExist = errors.New("namespace does not exist")
ErrNamespaceDoesNotExist is returned when a namespace does not exist for a resource that is attempting to be created in the specified namespace.
var ErrNotFound = errors.New("record not found")
ErrNotFound is returned when a database operation that is expected to find a record does not find the record.
var ErrProtected = errors.New("resource is protected")
ErrProtected is returned when an operation is attempted on a protected resource that cannot be modified in the requested way.
var ErrViolation = errors.New("database constraint violation")
ErrViolation is returned when a constraint in the database is violated (e.g. multiple rows with the same ID) after an operation that should have been unique.
var GlobalKeyID = apid.ID("key_global")
GlobalKeyID is the ID of the global key created by migration. It is the root of the key hierarchy and must not be deleted.
Functions ¶
func ApidPrefixToLabelToken ¶
ApidPrefixToLabelToken returns the label-key token associated with an apid prefix. It strips the trailing underscore so e.g. "cxr_" becomes "cxr" and "cxn_" becomes "cxn". Used to build apxy/ keys whose <rt> segment matches the resource's id prefix.
func BuildLabelSelectorFromMap ¶
BuildLabelSelectorFromMap creates a label selector string from key-value pairs. Keys are sorted for deterministic output. Example: {"type": "salesforce", "env": "prod"} -> "env=prod,type=salesforce"
func IsValidActorOrderByField ¶
func IsValidActorOrderByField[T string | ActorOrderByField](field T) bool
IsValidActorOrderByField checks if the given value is a valid ActorOrderByField.
func IsValidConnectionHealthState ¶
func IsValidConnectionHealthState[T string | ConnectionHealthState](state T) bool
func IsValidConnectionOrderByField ¶
func IsValidConnectionOrderByField[T string | ConnectionOrderByField](field T) bool
func IsValidConnectionState ¶
func IsValidConnectionState[T string | ConnectionState](state T) bool
func IsValidConnectorDefinitionVersionOrderByField ¶
func IsValidConnectorDefinitionVersionOrderByField[T string | ConnectorDefinitionVersionOrderByField](field T) bool
func IsValidConnectorDefinitionVersionState ¶
func IsValidConnectorDefinitionVersionState[T string | ConnectorDefinitionVersionState](state T) bool
func IsValidConnectorOrderByField ¶
func IsValidConnectorOrderByField[T string | ConnectorOrderByField](field T) bool
func IsValidKeyMaterialType ¶
func IsValidKeyMaterialType[T string | KeyMaterialType](materialType T) bool
func IsValidKeyOrderByField ¶
func IsValidKeyOrderByField[T string | KeyOrderByField](field T) bool
func IsValidKeyState ¶
func IsValidKeyUsage ¶
func IsValidNamespaceOrderByField ¶
func IsValidNamespaceOrderByField[T string | NamespaceOrderByField](field T) bool
func IsValidNamespaceState ¶
func IsValidNamespaceState[T string | NamespaceState](state T) bool
func IsValidNotificationLevel ¶
func IsValidNotificationLevel[T string | NotificationLevel](level T) bool
func IsValidNotificationState ¶
func IsValidNotificationState[T string | NotificationState](state T) bool
func IsValidRateLimitOrderByField ¶
func IsValidRateLimitOrderByField[T string | RateLimitOrderByField](field T) bool
func IsValidSearchResourceType ¶
func IsValidSearchResourceType(t SearchResourceType) bool
func RegisterEncryptedField ¶
func RegisterEncryptedField(reg EncryptedFieldRegistration)
RegisterEncryptedField adds an encrypted field registration to the global registry. Panics if the registration is invalid. Must be called during init().
func ValidateAnnotationKey ¶
ValidateAnnotationKey validates a single annotation key. Annotation keys follow the same format as label keys.
func ValidateAnnotationValue ¶
ValidateAnnotationValue validates a single annotation value. Annotation values have no format restriction — any string is allowed. Individual value size is not restricted; only the total annotations size is checked.
func ValidateAnnotations ¶
ValidateAnnotations validates all annotations in a map.
func ValidateApxyLabelValue ¶
ValidateApxyLabelValue validates a label value stored under an apxy/-prefixed key. It allows up to ApxyLabelValueMaxLength characters so namespace paths (e.g. root.foo.bar.baz...) can fit, including the leading underscores and trailing hyphens accepted in namespace path segments.
func ValidateLabelKey ¶
ValidateLabelKey validates a single label key.
Two grammars are accepted:
Standard Kubernetes-style key: [prefix/]name - prefix (optional): valid DNS subdomain, max 253 characters - name (required): 1-63 characters, must start/end with alphanumeric, may contain '-', '_', '.'
Reserved apxy/ multi-segment key: apxy/<seg>(/<seg>)*/<name> - each <seg> is a DNS-label-like token or the literal "-" sentinel - <name> follows the standard name rule above - total prefix portion (everything before the final '/') still capped at LabelKeyPrefixMaxLength characters
This function accepts apxy/ keys; user-input call sites should use ValidateUserLabelKey to additionally reject the reserved namespace.
func ValidateLabelValue ¶
ValidateLabelValue validates a single label value according to Kubernetes restrictions. - 0-63 characters (can be empty) - if non-empty: must start and end with alphanumeric, may contain alphanumeric, '-', '_', '.'
func ValidateLabels ¶
ValidateLabels validates all labels in a map. apxy/-prefixed keys are accepted (use ValidateUserLabels at user-input boundaries instead) and values stored under apxy/ keys are validated against the longer ApxyLabelValueMaxLength cap.
func ValidateUserLabelDeletionKeys ¶
ValidateUserLabelDeletionKeys validates a list of keys passed to a user-facing label-deletion endpoint. Keys must be well-formed and must not reference the reserved apxy/ namespace.
func ValidateUserLabelKey ¶
ValidateUserLabelKey validates a label key supplied directly by an end user. In addition to the rules of ValidateLabelKey, it rejects any key in the reserved apxy/ namespace — those keys are managed by the system and may not be set, modified, or deleted through user-input endpoints.
func ValidateUserLabels ¶
ValidateUserLabels validates a labels map supplied by a user. It applies the same key/value rules as ValidateLabels but rejects any key in the reserved apxy/ namespace.
Types ¶
type Actor ¶
type Actor struct {
Id apid.ID
Namespace string
Name scommon.ResourceName
ExternalId string
Permissions Permissions
Labels Labels
Annotations Annotations
EncryptedKey *encfield.EncryptedField
CreatedAt time.Time
UpdatedAt time.Time
EncryptedAt *time.Time
DeletedAt *time.Time
}
Actor is some entity taking action within the system.
func (*Actor) CanSelfSign ¶
CanSelfSign returns true if this actor has an encrypted key and can self-sign requests
func (*Actor) GetAnnotations ¶
func (*Actor) GetEncryptedKey ¶
func (a *Actor) GetEncryptedKey() *encfield.EncryptedField
func (*Actor) GetExternalId ¶
func (*Actor) GetName ¶
func (a *Actor) GetName() scommon.ResourceName
func (*Actor) GetNamespace ¶
func (*Actor) GetPermissions ¶
func (a *Actor) GetPermissions() []aschema.Permission
type ActorOrderByField ¶
type ActorOrderByField string
const ( ActorOrderByCreatedAt ActorOrderByField = "created_at" ActorOrderByUpdatedAt ActorOrderByField = "updated_at" ActorOrderByNamespace ActorOrderByField = "namespace" ActorOrderByExternalId ActorOrderByField = "external_id" ActorOrderByDeletedAt ActorOrderByField = "deleted_at" )
type Annotations ¶
Annotations is a map of key-value pairs similar to Kubernetes annotations. Keys follow the same format as label keys ([prefix/]name). Values have no format restriction — any string is allowed. Total size of all annotations (keys + values) must not exceed 256KB.
func (Annotations) Copy ¶
func (a Annotations) Copy() Annotations
Copy returns a deep copy of the annotations.
func (Annotations) Get ¶
func (a Annotations) Get(key string) (string, bool)
Get returns the value for an annotation key, and whether the key exists.
func (Annotations) Has ¶
func (a Annotations) Has(key string) bool
Has returns true if the annotation key exists.
func (*Annotations) Scan ¶
func (a *Annotations) Scan(value interface{}) error
Scan implements the sql.Scanner interface for Annotations
func (Annotations) Validate ¶
func (a Annotations) Validate() error
Validate validates all annotations.
type ApiKeyCredential ¶
type ApiKeyCredential struct {
Id apid.ID
ConnectionId apid.ID // FK to Connection; not enforced by DB
EncryptedCredentials encfield.EncryptedField // Opaque encrypted credential blob
PlacementSnapshot *cschema.ApiKeyPlacement // API-key placement config at submission time
CreatedByActorId *apid.ID // Actor who submitted (or rotated to) this credential
LastValidatedAt *time.Time // Most recent successful probe against this credential
CreatedAt time.Time
EncryptedAt *time.Time
DeletedAt *time.Time
}
ApiKeyCredential is one row in the connection_credentials table — an encrypted credential blob submitted by a user for a connection. API-key connections store api key material here; OAuth2 client_credentials connections store client id / secret material here. The encrypted_credentials column stores a single opaque encrypted blob; the substructure inside is decided by the encrypt/decrypt layer that owns the plaintext shape — the database is agnostic to it.
Rotation produces a new row and soft-deletes the prior, so the history of credentials is preserved. At most one row per connection has deleted_at IS NULL at any given moment.
func (*ApiKeyCredential) Validate ¶
func (c *ApiKeyCredential) Validate() error
type ApiKeyCredentialPlaintext ¶
type ApiKeyCredentialPlaintext struct {
ApiKey string `json:"apiKey"`
Username string `json:"username,omitempty"`
}
ApiKeyCredentialPlaintext is the canonical plaintext shape stored, encrypted, inside ApiKeyCredential.EncryptedCredentials. Defined here so callers that encrypt (the connection-initiate submit handler) and callers that decrypt (the api-key proxy) share one contract. The database itself never inspects the plaintext — it only stores the encrypted blob.
type Connection ¶
type Connection struct {
Id apid.ID
Namespace string
Name scommon.ResourceName
State ConnectionState
HealthState ConnectionHealthState
ConnectorId apid.ID
ConnectorVersion uint64
Labels Labels
Annotations Annotations
EncryptedConfiguration *encfield.EncryptedField
EncryptedAt *time.Time
SetupStep *cschema.SetupStep
SetupError *string
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
}
func (*Connection) GetAnnotations ¶
func (c *Connection) GetAnnotations() map[string]string
func (*Connection) GetConnectorId ¶
func (c *Connection) GetConnectorId() apid.ID
func (*Connection) GetConnectorVersion ¶
func (c *Connection) GetConnectorVersion() uint64
func (*Connection) GetId ¶
func (c *Connection) GetId() apid.ID
func (*Connection) GetLabels ¶
func (c *Connection) GetLabels() map[string]string
func (*Connection) GetNamespace ¶
func (c *Connection) GetNamespace() string
func (*Connection) Validate ¶
func (c *Connection) Validate() error
type ConnectionHealthState ¶
type ConnectionHealthState string
ConnectionHealthState is the operational health signal for a connection, distinct from its lifecycle state. A connection can be Configured and unhealthy simultaneously — for example, an OAuth2 connection whose refresh token has been revoked stays in ConnectionStateConfigured but flips to unhealthy until the user re-authenticates. Probe-driven and refresh-driven signals both write to this field; UI surfaces it to drive the unified reauth action.
const ( ConnectionHealthStateHealthy ConnectionHealthState = "healthy" ConnectionHealthStateUnhealthy ConnectionHealthState = "unhealthy" )
type ConnectionOrderByField ¶
type ConnectionOrderByField string
const ( ConnectionOrderById ConnectionOrderByField = "id" ConnectionOrderByNamespace ConnectionOrderByField = "namespace" ConnectionOrderByState ConnectionOrderByField = "state" ConnectionOrderByCreatedAt ConnectionOrderByField = "created_at" ConnectionOrderByUpdatedAt ConnectionOrderByField = "updated_at" )
type ConnectionProbeOutcome ¶
type ConnectionProbeOutcome struct {
Id apid.ID
ConnectionId apid.ID
ProbeId string
Outcome string
ErrorMessage *string
OccurredAt time.Time
CreatedAt time.Time
}
ConnectionProbeOutcome is one append-only event in the probe-outcome log. Each probe invocation produces a row; the runtime walks the most recent rows for a (connection_id, probe_id) pair to compute consecutive-success or -failure counts that drive the connection's health_state transitions.
Storage is event-shaped rather than counter-shaped so that:
- writes never race on a shared counter row;
- the log naturally carries probe history for operators (when did the last failure happen? what error did it report?);
- threshold semantics can change without a schema migration.
A daily cleanup task (DeleteOldProbeOutcomes) caps growth — see internal/core/task_probe_outcome_cleanup.go.
type ConnectionState ¶
type ConnectionState string
const ( // ConnectionStateSetup is the initial state — a connection in setup // has been persisted and has one or more setup steps in progress. ConnectionStateSetup ConnectionState = "setup" // ConnectionStateConfigured means setup is complete. The connection // may or may not be currently usable; whether the credentials still // work is the orthogonal ConnectionHealthState axis (e.g. an OAuth2 // connection with a revoked refresh token stays Configured but flips // unhealthy until reauth). ConnectionStateConfigured ConnectionState = "configured" ConnectionStateDisabled ConnectionState = "disabled" ConnectionStateDisconnecting ConnectionState = "disconnecting" ConnectionStateDisconnected ConnectionState = "disconnected" )
type ConnectionVersionMigrationUpdate ¶
type ConnectionVersionMigrationUpdate struct {
Id apid.ID
ConnectorId apid.ID
ConnectorVersion uint64
EncryptedConfiguration *encfield.EncryptedField
UserLabels map[string]string
Annotations map[string]string
SetupStep *cschema.SetupStep
SetupError *string
HealthState *ConnectionHealthState
}
ConnectionVersionMigrationUpdate is the complete connection row replacement produced by a connector-version migration. The database layer applies it in a single transaction so the target version, encrypted configuration, labels, annotations, setup state, and health state cannot be partially persisted.
type Connector ¶
type Connector struct {
Id apid.ID
Namespace string
Name scommon.ResourceName
Labels Labels
Annotations Annotations
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
}
Connector is the database representation of a logical connector. Definition versions are stored separately in connector_definition_versions.
type ConnectorDefinitionVersion ¶
type ConnectorDefinitionVersion struct {
Id apid.ID
ConnectorId apid.ID
Version uint64
State ConnectorDefinitionVersionState
EncryptedDefinition encfield.EncryptedField
CreatedAt time.Time
UpdatedAt time.Time
EncryptedAt *time.Time
DeletedAt *time.Time
}
ConnectorDefinitionVersion is the database representation of a single row in connector_definition_versions.
func (*ConnectorDefinitionVersion) Validate ¶
func (cv *ConnectorDefinitionVersion) Validate() error
type ConnectorDefinitionVersionOrderByField ¶
type ConnectorDefinitionVersionOrderByField string
const ( ConnectorDefinitionVersionOrderById ConnectorDefinitionVersionOrderByField = "id" ConnectorDefinitionVersionOrderByVersion ConnectorDefinitionVersionOrderByField = "version" ConnectorDefinitionVersionOrderByState ConnectorDefinitionVersionOrderByField = "state" ConnectorDefinitionVersionOrderByCreatedAt ConnectorDefinitionVersionOrderByField = "created_at" ConnectorDefinitionVersionOrderByUpdatedAt ConnectorDefinitionVersionOrderByField = "updated_at" )
type ConnectorDefinitionVersionState ¶
type ConnectorDefinitionVersionState string
const ( // ConnectorDefinitionVersionStateDraft means the connector definition is being worked on and new users should not connect to // this version and existing users should not be upgraded to this version ConnectorDefinitionVersionStateDraft ConnectorDefinitionVersionState = "draft" // ConnectorDefinitionVersionStatePrimary means that the version has been published and this should be the version used for // new connections. Existing connections of this connector will be upgraded to this version if possible, or // transitioned to a state where action is required to complete the upgrade. ConnectorDefinitionVersionStatePrimary ConnectorDefinitionVersionState = "primary" // ConnectorDefinitionVersionStateActive means that a newer version of the connector has been published, but connections // still exist on this version that have not been upgraded. ConnectorDefinitionVersionStateActive ConnectorDefinitionVersionState = "active" // ConnectorDefinitionVersionStateArchived means that this is an old version of the connect that does not have any active // connections running on the version. ConnectorDefinitionVersionStateArchived ConnectorDefinitionVersionState = "archived" )
func (*ConnectorDefinitionVersionState) Scan ¶
func (s *ConnectorDefinitionVersionState) Scan(value interface{}) error
Scan implements the sql.Scanner interface for ConnectorDefinitionVersionState
type ConnectorOrderByField ¶
type ConnectorOrderByField string
const ( ConnectorOrderById ConnectorOrderByField = "id" ConnectorOrderByVersion ConnectorOrderByField = "version" ConnectorOrderByNamespace ConnectorOrderByField = "namespace" ConnectorOrderByState ConnectorOrderByField = "state" ConnectorOrderByCreatedAt ConnectorOrderByField = "created_at" ConnectorOrderByUpdatedAt ConnectorOrderByField = "updated_at" ConnectorOrderByType ConnectorOrderByField = "type" )
type ConnectorWithDefinition ¶
type ConnectorWithDefinition struct {
Id apid.ID
Namespace string
Name scommon.ResourceName
DefinitionVersionId apid.ID
Version uint64
State ConnectorDefinitionVersionState
EncryptedDefinition encfield.EncryptedField
Labels Labels
Annotations Annotations
CreatedAt time.Time
UpdatedAt time.Time
DefinitionCreatedAt time.Time
DefinitionUpdatedAt time.Time
EncryptedAt *time.Time
DeletedAt *time.Time
}
ConnectorWithDefinition combines fields from connectors and connector_definition_versions.
func (*ConnectorWithDefinition) GetId ¶
func (cv *ConnectorWithDefinition) GetId() apid.ID
func (*ConnectorWithDefinition) GetNamespace ¶
func (cv *ConnectorWithDefinition) GetNamespace() string
func (*ConnectorWithDefinition) GetVersion ¶
func (cv *ConnectorWithDefinition) GetVersion() uint64
func (*ConnectorWithDefinition) Validate ¶
func (cv *ConnectorWithDefinition) Validate() error
type DB ¶
type DB interface {
SetCursorEncryptor(e pagination.CursorEncryptor)
Migrate(ctx context.Context) error
Ping(ctx context.Context) bool
SearchResources(ctx context.Context, params SearchResourcesParams) (SearchResourcesResult, error)
GetNamespace(ctx context.Context, path string) (*Namespace, error)
CreateNamespace(ctx context.Context, ns *Namespace) error
EnsureNamespaceByPath(ctx context.Context, path string) error
DeleteNamespace(ctx context.Context, path string) error
SetNamespaceState(ctx context.Context, path string, state NamespaceState) error
SetNamespaceKeyId(ctx context.Context, path string, ekId *apid.ID) (*Namespace, error)
UpdateNamespaceLabels(ctx context.Context, path string, labels map[string]string) (*Namespace, error)
PutNamespaceLabels(ctx context.Context, path string, labels map[string]string) (*Namespace, error)
DeleteNamespaceLabels(ctx context.Context, path string, keys []string) (*Namespace, error)
UpdateNamespaceAnnotations(ctx context.Context, path string, annotations map[string]string) (*Namespace, error)
PutNamespaceAnnotations(ctx context.Context, path string, annotations map[string]string) (*Namespace, error)
DeleteNamespaceAnnotations(ctx context.Context, path string, keys []string) (*Namespace, error)
ListNamespacesBuilder() ListNamespacesBuilder
ListNamespacesFromCursor(ctx context.Context, cursor string) (ListNamespacesExecutor, error)
EnumerateNamespaceEncryptionTargets(
ctx context.Context,
callback func(targets []NamespaceEncryptionTarget, lastPage bool) (updates []NamespaceTargetDataEncryptionKeyUpdate, keepGoing pagination.KeepGoing, err error),
) error
GetActor(ctx context.Context, id apid.ID) (*Actor, error)
GetActorByExternalId(ctx context.Context, namespace, externalId string) (*Actor, error)
CreateActor(ctx context.Context, actor *Actor) error
UpsertActor(ctx context.Context, actor IActorData) (*Actor, error)
UpdateActorName(ctx context.Context, id apid.ID, name scommon.ResourceName) (*Actor, error)
DeleteActor(ctx context.Context, id apid.ID) error
PutActorLabels(ctx context.Context, id apid.ID, labels map[string]string) (*Actor, error)
DeleteActorLabels(ctx context.Context, id apid.ID, keys []string) (*Actor, error)
UpdateActorAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*Actor, error)
PutActorAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*Actor, error)
DeleteActorAnnotations(ctx context.Context, id apid.ID, keys []string) (*Actor, error)
ListActorsBuilder() ListActorsBuilder
ListActorsFromCursor(ctx context.Context, cursor string) (ListActorsExecutor, error)
GetConnectorDefinitionVersion(ctx context.Context, id apid.ID, version uint64) (*ConnectorWithDefinition, error)
GetConnectorDefinitionVersions(ctx context.Context, requested []ConnectorDefinitionVersionId) (map[ConnectorDefinitionVersionId]*ConnectorWithDefinition, error)
GetConnectorDefinitionVersionForState(ctx context.Context, id apid.ID, state ConnectorDefinitionVersionState) (*ConnectorWithDefinition, error)
NewestConnectorDefinitionVersionForId(ctx context.Context, id apid.ID) (*ConnectorWithDefinition, error)
NewestPublishedConnectorDefinitionVersionForId(ctx context.Context, id apid.ID) (*ConnectorWithDefinition, error)
UpsertConnectorDefinitionVersion(ctx context.Context, cv *ConnectorWithDefinition) error
SetConnectorDefinitionVersionState(ctx context.Context, id apid.ID, version uint64, state ConnectorDefinitionVersionState) error
UpdateConnectorName(ctx context.Context, id apid.ID, name scommon.ResourceName) error
DeleteConnector(ctx context.Context, id apid.ID) error
ListConnectorDefinitionVersionsBuilder() ListConnectorDefinitionVersionsBuilder
ListConnectorDefinitionVersionsFromCursor(ctx context.Context, cursor string) (ListConnectorDefinitionVersionsExecutor, error)
ListConnectorsBuilder() ListConnectorsBuilder
ListConnectorsFromCursor(ctx context.Context, cursor string) (ListConnectorsExecutor, error)
GetConnection(ctx context.Context, id apid.ID) (*Connection, error)
CreateConnection(ctx context.Context, c *Connection) error
UpdateConnectionName(ctx context.Context, id apid.ID, name scommon.ResourceName) (*Connection, error)
DeleteConnection(ctx context.Context, id apid.ID) error
SetConnectionState(ctx context.Context, id apid.ID, state ConnectionState) error
SetConnectionHealthState(ctx context.Context, id apid.ID, state ConnectionHealthState) error
SetConnectionSetupStep(ctx context.Context, id apid.ID, setupStep *cschema.SetupStep) error
SetConnectionSetupError(ctx context.Context, id apid.ID, setupError *string) error
SetConnectionEncryptedConfiguration(ctx context.Context, id apid.ID, encryptedConfig *encfield.EncryptedField) error
UpdateConnectionLabels(ctx context.Context, id apid.ID, labels map[string]string) (*Connection, error)
PutConnectionLabels(ctx context.Context, id apid.ID, labels map[string]string) (*Connection, error)
DeleteConnectionLabels(ctx context.Context, id apid.ID, keys []string) (*Connection, error)
UpdateConnectionAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*Connection, error)
PutConnectionAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*Connection, error)
DeleteConnectionAnnotations(ctx context.Context, id apid.ID, keys []string) (*Connection, error)
UpdateConnectionForVersionMigration(ctx context.Context, update ConnectionVersionMigrationUpdate) (*Connection, error)
ListConnectionsBuilder() ListConnectionsBuilder
ListConnectionsFromCursor(ctx context.Context, cursor string) (ListConnectionsExecutor, error)
/*
* Notifications
*/
UpsertNotification(ctx context.Context, upsert NotificationUpsert) (*Notification, error)
GetNotification(ctx context.Context, id apid.ID) (*Notification, error)
ListNotifications(ctx context.Context, opts ListNotificationsOptions) ([]Notification, error)
MarkNotificationViewed(ctx context.Context, notificationID apid.ID, actorID apid.ID) error
MarkNotificationsViewed(ctx context.Context, notificationIDs []apid.ID, actorID apid.ID) error
NotificationViewedMap(ctx context.Context, actorID apid.ID, ids []apid.ID) (map[apid.ID]time.Time, error)
ResolveNotificationsForResourceKeys(ctx context.Context, resourceType string, resourceID apid.ID, keys []string) error
/*
* OAuth2 tokens
*/
GetOAuth2Token(ctx context.Context, connectionId apid.ID) (*OAuth2Token, error)
InsertOAuth2Token(
ctx context.Context,
connectionId apid.ID,
refreshedFrom *apid.ID,
encryptedRefreshToken encfield.EncryptedField,
encryptedAccessToken encfield.EncryptedField,
accessTokenExpiresAt *time.Time,
scopes string,
requestedScopes string,
createdByActorId *apid.ID,
) (*OAuth2Token, error)
DeleteOAuth2Token(ctx context.Context, tokenId apid.ID) error
DeleteAllOAuth2TokensForConnection(ctx context.Context, connectionId apid.ID) error
// EnumerateOAuth2TokensExpiringWithin enumerates OAuth2 tokens that are expiring within a specified time interval
// of now. This includes tokens that are already expired. Deleted tokens are not considered, nor are tokens tied
// to a deleted connection.
EnumerateOAuth2TokensExpiringWithin(
ctx context.Context,
duration time.Duration,
callback func(tokens []*OAuth2TokenWithConnection, lastPage bool) (keepGoing pagination.KeepGoing, err error),
) error
/*
* API Key credentials
*/
GetActiveApiKeyCredential(ctx context.Context, connectionId apid.ID) (*ApiKeyCredential, error)
InsertApiKeyCredential(
ctx context.Context,
connectionId apid.ID,
encryptedCredentials encfield.EncryptedField,
placement *cschema.ApiKeyPlacement,
createdByActorId *apid.ID,
) (*ApiKeyCredential, error)
UpdateApiKeyCredentialLastValidated(ctx context.Context, credentialId apid.ID, at time.Time) error
DeleteAllApiKeyCredentialsForConnection(ctx context.Context, connectionId apid.ID) error
/*
* Connection probe outcomes — append-only event log that drives the
* probe-driven health-check signal. The runtime walks the most-recent
* rows for each (connection_id, probe_id) to compute consecutive-success
* or -failure counts. A daily cleanup task caps growth (see
* internal/core/task_probe_outcome_cleanup.go).
*/
InsertProbeOutcome(ctx context.Context, connectionId apid.ID, probeId string, outcome string, errorMessage string) (*ConnectionProbeOutcome, error)
GetRecentProbeOutcomes(ctx context.Context, connectionId apid.ID, probeId string, limit int) ([]*ConnectionProbeOutcome, error)
DeleteOldProbeOutcomes(ctx context.Context, connectionId apid.ID, probeId string, keepMinimum int, olderThan time.Time) (int64, error)
DistinctProbeIdsForConnection(ctx context.Context, connectionId apid.ID) ([]string, error)
CountProbeOutcomes(ctx context.Context, connectionId apid.ID, probeId string) (int, error)
GetKey(ctx context.Context, id apid.ID) (*Key, error)
CreateKey(ctx context.Context, ek *Key) error
UpdateKeyName(ctx context.Context, id apid.ID, name scommon.ResourceName) (*Key, error)
UpdateKey(ctx context.Context, id apid.ID, updates map[string]interface{}) (*Key, error)
DeleteKey(ctx context.Context, id apid.ID) error
SetKeyState(ctx context.Context, id apid.ID, state KeyState) error
UpdateKeyLabels(ctx context.Context, id apid.ID, labels map[string]string) (*Key, error)
PutKeyLabels(ctx context.Context, id apid.ID, labels map[string]string) (*Key, error)
DeleteKeyLabels(ctx context.Context, id apid.ID, keys []string) (*Key, error)
UpdateKeyAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*Key, error)
PutKeyAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*Key, error)
DeleteKeyAnnotations(ctx context.Context, id apid.ID, keys []string) (*Key, error)
ListKeysBuilder() ListKeysBuilder
ListKeysFromCursor(ctx context.Context, cursor string) (ListKeysExecutor, error)
// EnumerateKeysInDependencyOrder loads all non-deleted keys and walks them
// in breadth-first order starting from the root key (the one with nil EncryptedKeyData).
// The callback receives one depth-level of keys at a time, with depth 0 being the root.
// Returns a slice of orphaned keys whose parent key could not be resolved.
EnumerateKeysInDependencyOrder(
ctx context.Context,
callback func(keys []*Key, depth int) (keepGoing pagination.KeepGoing, err error),
) ([]*Key, error)
CreateDataEncryptionKey(ctx context.Context, dek *DataEncryptionKey) error
GetDataEncryptionKey(ctx context.Context, id apid.ID) (*DataEncryptionKey, error)
GetCurrentDataEncryptionKeyForKey(ctx context.Context, keyId apid.ID) (*DataEncryptionKey, error)
UpdateDataEncryptionKeyWrapping(ctx context.Context, dek *DataEncryptionKey) error
ClearCurrentDataEncryptionKeyFlagForKey(ctx context.Context, keyId apid.ID) error
SetDataEncryptionKeyCurrentFlag(ctx context.Context, id apid.ID, isCurrent bool) error
ListDataEncryptionKeysForKey(ctx context.Context, keyId apid.ID) ([]*DataEncryptionKey, error)
EnumerateDataEncryptionKeysForKey(
ctx context.Context,
keyId apid.ID,
callback func(deks []*DataEncryptionKey, lastPage bool) (keepGoing pagination.KeepGoing, err error),
) error
GetRateLimit(ctx context.Context, id apid.ID) (*RateLimit, error)
CreateRateLimit(ctx context.Context, rl *RateLimit) error
UpdateRateLimitName(ctx context.Context, id apid.ID, name scommon.ResourceName) (*RateLimit, error)
UpdateRateLimitDefinition(ctx context.Context, id apid.ID, def rlschema.RateLimit) (*RateLimit, error)
DeleteRateLimit(ctx context.Context, id apid.ID) error
UpdateRateLimitLabels(ctx context.Context, id apid.ID, labels map[string]string) (*RateLimit, error)
PutRateLimitLabels(ctx context.Context, id apid.ID, labels map[string]string) (*RateLimit, error)
DeleteRateLimitLabels(ctx context.Context, id apid.ID, keys []string) (*RateLimit, error)
UpdateRateLimitAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*RateLimit, error)
PutRateLimitAnnotations(ctx context.Context, id apid.ID, annotations map[string]string) (*RateLimit, error)
DeleteRateLimitAnnotations(ctx context.Context, id apid.ID, keys []string) (*RateLimit, error)
ListRateLimitsBuilder() ListRateLimitsBuilder
ListRateLimitsFromCursor(ctx context.Context, cursor string) (ListRateLimitsExecutor, error)
// EnumerateFieldsRequiringReEncryption walks all registered encrypted fields across all tables,
// finding rows whose encrypted field EKV ID does not match the namespace's target EKV ID.
EnumerateFieldsRequiringReEncryption(
ctx context.Context,
callback func(targets []ReEncryptionTarget, lastPage bool) (keepGoing pagination.KeepGoing, err error),
) error
// BatchUpdateReEncryptedFields updates encrypted field values after re-encryption,
// setting the new value and updating encrypted_at.
BatchUpdateReEncryptedFields(ctx context.Context, updates []ReEncryptedFieldUpdate) error
// PurgeSoftDeletedRecords hard-deletes all soft-deleted records where deleted_at is before olderThan.
// Returns the total number of records deleted across all tables.
PurgeSoftDeletedRecords(ctx context.Context, olderThan time.Time) (int64, error)
// RefreshNamespaceLabelsCarryForward re-derives the materialized apxy/
// portion of every resource that inherits from nsPath, then walks each
// direct child namespace, recomputes its labels, and recurses. Each
// row's update runs in its own short transaction. Intended to be
// invoked from a background asynq task — a label change on a deeply
// nested namespace can fan out to many descendants.
RefreshNamespaceLabelsCarryForward(ctx context.Context, nsPath string) error
// RefreshConnectionsForConnector re-derives the materialized
// apxy/ portion of every connection pointing at the given logical
// connector. Each connection's update runs in its own short
// transaction. Intended to be invoked from a background asynq task
// after a connector's user labels change.
RefreshConnectionsForConnector(ctx context.Context, id apid.ID) error
// ReconcileCarryForwardLabels walks every labelled resource in batches
// of `batchSize` and re-derives the materialized apxy/ portion of
// each row. The optional `limiter` is consulted before each row is
// processed, providing a per-row records/sec rate limit; nil means
// unlimited. Drift is rare under normal operation, but this method
// is the safety net for any propagation task that misfired or any
// data path that bypassed the carry-forward triggers. Intended to be
// invoked from a daily asynq cron task. Returns the total number of
// rows whose labels were corrected.
ReconcileCarryForwardLabels(ctx context.Context, batchSize int32, limiter *rate.Limiter) (corrected int64, err error)
HasNonceBeenUsed(ctx context.Context, nonce apid.ID) (hasBeenUsed bool, err error)
CheckNonceValidAndMarkUsed(ctx context.Context, nonce apid.ID, retainRecordUntil time.Time) (wasValid bool, err error)
DeleteExpiredNonces(ctx context.Context) (err error)
}
func MustApplyBlankTestDbConfig ¶
MustApplyBlankTestDbConfig applies a test database configuration to the specified config root. The database is guaranteed to be blank and migrated. This method uses a temp file so that the database will be eventually cleaned up after the process exits. Note that the configuration in the root will be modified for the database and populated for the GlobalAESKey if it is not already populated.
To support debugging tests by inspecting the SQLite database, if the SQLITE_TEST_DATABASE_PATH env var is set this method will use the database at that path. It will delete the existing file at that path to recreate unless the SQLITE_TEST_DATABASE_PATH_CLEAR env var is set to false.
To run tests against Postgres, set AUTH_PROXY_TEST_DATABASE_PROVIDER=postgres and configure the connection with POSTGRES_TEST_HOST, POSTGRES_TEST_PORT, POSTGRES_TEST_USER, POSTGRES_TEST_PASSWORD, POSTGRES_TEST_DATABASE, and POSTGRES_TEST_OPTIONS. You can also tune POSTGRES_TEST_MAX_PARALLEL and POSTGRES_TEST_MAX_CONNS to reduce connection pressure.
Parameters: - t: the test instance used for naming and cleanup - cfg: the config to apply the database config to. This may be nil, in which case a new config is created. This method will overwrite the existing config.
Returns: - the config with information populated for the database. If a config was passed in, the same value is returned with data populated. - a database instance configured with the specified root. This database can be used directly, or if the root used again, it will connect to the same database instance.
func NewService ¶
NewService creates the AuthProxy database service using an already-open and fully configured database/sql handle. The caller owns the SQL handle and is responsible for closing it.
type DataEncryptionKey ¶
type DataEncryptionKey struct {
Id apid.ID
KeyId apid.ID
Provider string
ProviderID string
ProviderVersion string
ProviderMetadata DataEncryptionKeyProviderMetadata
ProtectedData *sconfig.KeyVersionProtectedData
IsCurrent bool
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
}
func (*DataEncryptionKey) Validate ¶
func (d *DataEncryptionKey) Validate() error
type DataEncryptionKeyProviderMetadata ¶
func (*DataEncryptionKeyProviderMetadata) Scan ¶
func (m *DataEncryptionKeyProviderMetadata) Scan(value interface{}) error
type DeletedHandling ¶
type DeletedHandling bool
const ( // DeletedHandlingExclude will exclude deleted records from the result set DeletedHandlingExclude DeletedHandling = false // DeletedHandlingInclude will include deleted records in the result set DeletedHandlingInclude DeletedHandling = true )
type EncryptedFieldRegistration ¶
type EncryptedFieldRegistration struct {
Table string
PrimaryKeyCols []string // e.g. ["id"] or ["id", "version"]
EncryptedCols []string // e.g. ["encrypted_access_token", "encrypted_refresh_token"]
// Direct namespace resolution (most tables)
NamespaceCol string // e.g. "namespace" — column on this table
// Indirect namespace resolution via JOIN (e.g. oauth2_tokens → connections)
JoinTable string // e.g. "connections"
JoinLocalCol string // e.g. "connection_id" — FK column on this table
JoinRemoteCol string // e.g. "id" — PK column on join table
JoinNamespaceCol string // e.g. "namespace" — namespace column on join table
}
EncryptedFieldRegistration declares which columns on a table contain encrypted fields and how the table resolves to a namespace.
func GetEncryptedFieldRegistrations ¶
func GetEncryptedFieldRegistrations() []EncryptedFieldRegistration
GetEncryptedFieldRegistrations returns a copy of all registered encrypted field registrations.
type IActorData ¶
type IActorData interface {
GetId() apid.ID
GetExternalId() string
GetPermissions() []aschema.Permission
GetNamespace() string
GetLabels() map[string]string
// GetAnnotations returns the annotations to apply on upsert. A nil return means
// annotations should be left unchanged on existing actors (PATCH semantics);
// a non-nil map (including empty) is treated as a full replacement.
GetAnnotations() map[string]string
}
type IActorDataExtended ¶
type IActorDataExtended interface {
IActorData
GetEncryptedKey() *encfield.EncryptedField
}
IActorDataExtended extends IActorData with additional fields for labels and encrypted key. This interface is used when creating or updating actors with extended data such as labels for tracking the source of admin syncs, or encrypted keys for admin authentication.
type Key ¶
type Key struct {
Id apid.ID
Namespace string
Name scommon.ResourceName
Usage KeyUsage
MaterialType KeyMaterialType
// Key provider configuration is encrypted at rest, but it is not registered
// with namespace re-encryption. It defines the key hierarchy, so rewrapping
// it based on namespace targets can make a key depend on its own DEK.
EncryptedKeyData *encfield.EncryptedField
State KeyState
Labels Labels
Annotations Annotations
CreatedAt time.Time
UpdatedAt time.Time
EncryptedAt *time.Time
DeletedAt *time.Time
}
Key represents a user-managed key configuration.
func (*Key) GetNamespace ¶
type KeyMaterialType ¶
type KeyMaterialType string
const ( KeyMaterialTypeSymmetric KeyMaterialType = "symmetric" KeyMaterialTypePublic KeyMaterialType = "public" KeyMaterialTypePrivate KeyMaterialType = "private" KeyMaterialTypeExternal KeyMaterialType = "external" )
type KeyOrderByField ¶
type KeyOrderByField string
const ( KeyOrderByState KeyOrderByField = "state" KeyOrderByCreatedAt KeyOrderByField = "created_at" KeyOrderByUpdatedAt KeyOrderByField = "updated_at" )
type LabelOperator ¶
type LabelOperator string
const ( LabelOperatorEqual LabelOperator = "=" LabelOperatorNotEqual LabelOperator = "!=" LabelOperatorExists LabelOperator = "exists" LabelOperatorNotExists LabelOperator = "!exists" )
type LabelRequirement ¶
type LabelRequirement struct {
Key string
Operator LabelOperator
Value string
}
type LabelSelector ¶
type LabelSelector []LabelRequirement
func ParseLabelSelector ¶
func ParseLabelSelector(selector string) (LabelSelector, error)
ParseLabelSelector parses a Kubernetes-style label selector string. Supported syntax: - key=value, key==value - key!=value - key (exists) - !key (does not exist)
func (LabelSelector) ApplyToSqlBuilderWithProvider ¶
func (s LabelSelector) ApplyToSqlBuilderWithProvider(q sq.SelectBuilder, labelsColumn string, provider config.DatabaseProvider) sq.SelectBuilder
func (LabelSelector) Matches ¶
func (s LabelSelector) Matches(labels map[string]string) bool
Matches reports whether the supplied label map satisfies every requirement in the selector. An empty / nil selector matches any input — same convention the SQL-side uses (no requirements means no filter).
This is the in-memory counterpart to ApplyToSqlBuilderWithProvider used by the rate-limit evaluator (and any future runtime path that needs to match label selectors against per-request snapshots).
func (LabelSelector) String ¶
func (s LabelSelector) String() string
type Labels ¶
Labels is a map of key-value pairs following Kubernetes label restrictions. Keys follow the format [prefix/]name where: - prefix (optional): valid DNS subdomain, max 253 characters - name (required): 1-63 characters, alphanumeric start/end, may contain '-', '_', '.' Values: 0-63 characters, if non-empty must start/end with alphanumeric
func ApplyParentCarryForward ¶
func ApplyParentCarryForward(userLabels Labels, parents ...ParentCarryForward) Labels
ApplyParentCarryForward composes a child resource's labels from the parents listed and the user-supplied labels. For each parent it calls BuildCarriedLabels(parent.Rt, parent.Labels) and merges the result; the user's own labels are merged last among non-self entries (they cannot collide with apxy/ keys because user input cannot reference the apxy/ namespace). Parents are applied in order, so a later parent's apxy/ pass-through overrides an earlier parent's — list parents from most distant to most direct so the most direct ancestor wins on conflicts (deeper-overrides-shallower).
Callers should follow with InjectSelfImplicitLabels (or InjectNamespaceSelfImplicitLabels for path-keyed namespaces) so the child's own self-implicit labels override any same-keyed pass-through from a parent.
func BuildCarriedLabels ¶
BuildCarriedLabels takes a parent's labels and returns the carry-forward labels for a child of the parent.
- User labels on the parent (any key NOT starting with apxy/) are re-keyed under apxy/<parentRt>/<key>.
- apxy/-prefixed labels on the parent are forwarded as-is so that ancestors further up the chain remain visible. The child is expected to merge its own self-implicit labels on top of this map (deeper overrides shallower).
parentRt is the resource-type token of the parent (e.g. "cxr", "cxn", "ns") — typically obtained via ApidPrefixToLabelToken.
func BuildImplicitResourceLabels ¶
func BuildImplicitResourceLabels(id apid.ID, name scommon.ResourceName, namespacePath string) Labels
BuildImplicitResourceLabels returns the three implicit identity labels for an apid-keyed resource: apxy/<rt>/-/id, apxy/<rt>/-/name, and apxy/<rt>/-/ns, where <rt> is derived from the resource's id prefix.
func BuildImplicitResourceLabelsForToken ¶
func BuildImplicitResourceLabelsForToken(rt, id string, name scommon.ResourceName, namespacePath string) Labels
BuildImplicitResourceLabelsForToken builds the apxy/<rt>/-/id, apxy/<rt>/-/name, and apxy/<rt>/-/ns implicit identity labels for any resource type, keyed by the supplied <rt> token and identifier string. This is the underlying builder used by both apid-keyed and path-keyed resources.
func BuildNamespaceImplicitResourceLabels ¶
BuildNamespaceImplicitResourceLabels builds a namespace's self-implicit identity labels. Both -/id and -/ns carry the namespace path, while -/name carries the final path segment.
func InjectNamespaceSelfImplicitLabels ¶
InjectNamespaceSelfImplicitLabels returns a copy of existing with a namespace's own apxy/ns/-/id, apxy/ns/-/name, and apxy/ns/-/ns labels added. Mirrors InjectSelfImplicitLabels but for path-keyed namespace resources.
func InjectSelfImplicitLabels ¶
func InjectSelfImplicitLabels(id apid.ID, name scommon.ResourceName, namespacePath string, existing Labels) Labels
InjectSelfImplicitLabels returns a copy of existing with the resource's own apxy/<rt>/-/id, apxy/<rt>/-/name, and apxy/<rt>/-/ns labels added. The self-implicit labels override any same-keyed entries already in existing (deeper-overrides- shallower across the carry-forward chain). Callers pass this to the create path so the row is persisted with the implicit identity labels in place.
func MergeApxyAndUserLabels ¶
MergeApxyAndUserLabels returns a single map containing both the user and apxy portions. Because the two inputs are partitioned by key prefix, no collisions are possible.
func MergeUpsertLabels ¶
MergeUpsertLabels composes the labels to persist on an upsert by combining caller-supplied labels with the row's existing apxy/ labels.
User-portion labels come from the caller — fully replacing what was stored (write-API endpoints that PATCH user labels go through a different helper). apxy/-prefixed labels merge: stored values are preserved by default, and any apxy/-prefixed entries the caller passes in override the stored values for those specific keys. This lets system code update its own provenance markers (e.g. apxy/cxr/source) on an upsert without requiring a separate label-mutation call, while still preserving apxy/ labels owned by other subsystems (e.g. carry-forward materializations).
func SplitUserAndApxyLabels ¶
SplitUserAndApxyLabels partitions a labels map into the user-provided portion (no apxy/ prefix) and the system-managed portion (apxy/ prefix). The two returned maps are disjoint and together reconstitute the input. Either map may be nil if its half is empty.
type ListActorsBuilder ¶
type ListActorsBuilder interface {
ListActorsExecutor
ForExternalId(externalId string) ListActorsBuilder
ForName(name scommon.ResourceName) ListActorsBuilder
ForNamespaceMatcher(matcher string) ListActorsBuilder
ForNamespaceMatchers(matchers []string) ListActorsBuilder
Limit(int32) ListActorsBuilder
OrderBy(ActorOrderByField, pagination.OrderBy) ListActorsBuilder
IncludeDeleted() ListActorsBuilder
ForLabelSelector(selector string) ListActorsBuilder
}
type ListActorsExecutor ¶
type ListActorsExecutor interface {
FetchPage(context.Context) pagination.PageResult[*Actor]
Enumerate(context.Context, pagination.EnumerateCallback[*Actor]) error
}
type ListConnectionsBuilder ¶
type ListConnectionsBuilder interface {
ListConnectionsExecutor
Limit(int32) ListConnectionsBuilder
ForState(ConnectionState) ListConnectionsBuilder
ForStates([]ConnectionState) ListConnectionsBuilder
ForConnectorId(id apid.ID) ListConnectionsBuilder
ForNamespaceMatcher(matcher string) ListConnectionsBuilder
ForNamespaceMatchers(matchers []string) ListConnectionsBuilder
ForName(name scommon.ResourceName) ListConnectionsBuilder
OrderBy(ConnectionOrderByField, pagination.OrderBy) ListConnectionsBuilder
IncludeDeleted() ListConnectionsBuilder
WithDeletedHandling(DeletedHandling) ListConnectionsBuilder
ForLabelSelector(selector string) ListConnectionsBuilder
WithSetupStepNotNull() ListConnectionsBuilder
UpdatedBefore(t time.Time) ListConnectionsBuilder
}
type ListConnectionsExecutor ¶
type ListConnectionsExecutor interface {
FetchPage(context.Context) pagination.PageResult[Connection]
Enumerate(context.Context, pagination.EnumerateCallback[Connection]) error
}
type ListConnectorDefinitionVersionsBuilder ¶
type ListConnectorDefinitionVersionsBuilder interface {
ListConnectorDefinitionVersionsExecutor
Limit(int32) ListConnectorDefinitionVersionsBuilder
ForId(apid.ID) ListConnectorDefinitionVersionsBuilder
ForVersion(uint64) ListConnectorDefinitionVersionsBuilder
ForState(ConnectorDefinitionVersionState) ListConnectorDefinitionVersionsBuilder
ForStates([]ConnectorDefinitionVersionState) ListConnectorDefinitionVersionsBuilder
ForNamespaceMatcher(string) ListConnectorDefinitionVersionsBuilder
ForNamespaceMatchers([]string) ListConnectorDefinitionVersionsBuilder
ForName(name scommon.ResourceName) ListConnectorDefinitionVersionsBuilder
OrderBy(ConnectorDefinitionVersionOrderByField, pagination.OrderBy) ListConnectorDefinitionVersionsBuilder
IncludeDeleted() ListConnectorDefinitionVersionsBuilder
ForLabelSelector(selector string) ListConnectorDefinitionVersionsBuilder
}
type ListConnectorDefinitionVersionsExecutor ¶
type ListConnectorDefinitionVersionsExecutor interface {
FetchPage(context.Context) pagination.PageResult[ConnectorWithDefinition]
Enumerate(context.Context, pagination.EnumerateCallback[ConnectorWithDefinition]) error
}
type ListConnectorsBuilder ¶
type ListConnectorsBuilder interface {
ListConnectorsExecutor
Limit(int32) ListConnectorsBuilder
ForType(string) ListConnectorsBuilder
ForId(apid.ID) ListConnectorsBuilder
ForNamespaceMatcher(string) ListConnectorsBuilder
ForNamespaceMatchers([]string) ListConnectorsBuilder
ForName(name scommon.ResourceName) ListConnectorsBuilder
ForState(ConnectorDefinitionVersionState) ListConnectorsBuilder
ForStates([]ConnectorDefinitionVersionState) ListConnectorsBuilder
OrderBy(ConnectorOrderByField, pagination.OrderBy) ListConnectorsBuilder
IncludeDeleted() ListConnectorsBuilder
ForLabelSelector(selector string) ListConnectorsBuilder
}
type ListConnectorsExecutor ¶
type ListConnectorsExecutor interface {
FetchPage(context.Context) pagination.PageResult[ConnectorWithDefinition]
Enumerate(context.Context, pagination.EnumerateCallback[ConnectorWithDefinition]) error
}
type ListKeysBuilder ¶
type ListKeysBuilder interface {
ListKeysExecutor
Limit(int32) ListKeysBuilder
ForNamespaceMatcher(matcher string) ListKeysBuilder
ForNamespaceMatchers(matchers []string) ListKeysBuilder
ForName(name scommon.ResourceName) ListKeysBuilder
ForState(KeyState) ListKeysBuilder
OrderBy(KeyOrderByField, pagination.OrderBy) ListKeysBuilder
IncludeDeleted() ListKeysBuilder
ForLabelSelector(selector string) ListKeysBuilder
}
type ListKeysExecutor ¶
type ListKeysExecutor interface {
FetchPage(context.Context) pagination.PageResult[Key]
Enumerate(context.Context, pagination.EnumerateCallback[Key]) error
}
type ListNamespacesBuilder ¶
type ListNamespacesBuilder interface {
ListNamespacesExecutor
Limit(int32) ListNamespacesBuilder
ForPathPrefix(path string) ListNamespacesBuilder
ForDepth(depth uint64) ListNamespacesBuilder
ForChildrenOf(path string) ListNamespacesBuilder
ForNamespaceMatcher(matcher string) ListNamespacesBuilder
ForNamespaceMatchers(matchers []string) ListNamespacesBuilder
ForName(name scommon.ResourceName) ListNamespacesBuilder
ForState(NamespaceState) ListNamespacesBuilder
OrderBy(NamespaceOrderByField, pagination.OrderBy) ListNamespacesBuilder
IncludeDeleted() ListNamespacesBuilder
ForLabelSelector(selector string) ListNamespacesBuilder
}
type ListNamespacesExecutor ¶
type ListNamespacesExecutor interface {
FetchPage(context.Context) pagination.PageResult[Namespace]
Enumerate(context.Context, pagination.EnumerateCallback[Namespace]) error
}
type ListRateLimitsBuilder ¶
type ListRateLimitsBuilder interface {
ListRateLimitsExecutor
Limit(int32) ListRateLimitsBuilder
ForNamespaceMatcher(matcher string) ListRateLimitsBuilder
ForNamespaceMatchers(matchers []string) ListRateLimitsBuilder
ForName(name scommon.ResourceName) ListRateLimitsBuilder
OrderBy(RateLimitOrderByField, pagination.OrderBy) ListRateLimitsBuilder
IncludeDeleted() ListRateLimitsBuilder
ForLabelSelector(selector string) ListRateLimitsBuilder
}
type ListRateLimitsExecutor ¶
type ListRateLimitsExecutor interface {
FetchPage(context.Context) pagination.PageResult[RateLimit]
Enumerate(context.Context, pagination.EnumerateCallback[RateLimit]) error
}
type Namespace ¶
type Namespace struct {
Path string
State NamespaceState
KeyId *apid.ID
TargetDataEncryptionKeyId *apid.ID
Labels Labels
Annotations Annotations
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
// contains filtered or unexported fields
}
Namespace is the grouping of resources within AuthProxy.
func (*Namespace) GetNamespace ¶
type NamespaceEncryptionTarget ¶
type NamespaceEncryptionTarget struct {
Path string
Depth uint64
KeyId *apid.ID
TargetDataEncryptionKeyId *apid.ID
}
NamespaceEncryptionTarget holds the fields needed by the background job that computes and caches the target data encryption key for each namespace.
type NamespaceOrderByField ¶
type NamespaceOrderByField string
const ( NamespaceOrderByPath NamespaceOrderByField = "path" NamespaceOrderByState NamespaceOrderByField = "state" NamespaceOrderByCreatedAt NamespaceOrderByField = "created_at" NamespaceOrderByUpdatedAt NamespaceOrderByField = "updated_at" )
type NamespaceState ¶
type NamespaceState string
const ( NamespaceStateActive NamespaceState = "active" NamespaceStateDestroying NamespaceState = "destroying" NamespaceStateDestroyed NamespaceState = "destroyed" )
type NamespaceTargetDataEncryptionKeyUpdate ¶
type NamespaceTargetDataEncryptionKeyUpdate struct {
Path string
TargetDataEncryptionKeyId apid.ID
}
NamespaceTargetDataEncryptionKeyUpdate carries an update to set the target data encryption key for a specific namespace.
type Notification ¶
type Notification struct {
// Id is the stable notification id, e.g. "ntf_...".
Id apid.ID
// Key is the deterministic dedupe key for the notification condition.
// Reusing the same key upserts the active row instead of creating another
// notification; for example:
// "connection:cxn_...:auth_required".
Key string
// Level describes severity for presentation, such as "info" or "warning".
Level NotificationLevel
// State is "active" while the notification is visible and "resolved" once
// the underlying condition no longer applies.
State NotificationState
// ResourceType names the resource that owns this notification, e.g.
// "connection".
ResourceType string
// ResourceId is the owning resource id, e.g. a "cxn_..." connection id.
ResourceId apid.ID
// Namespace is the owning resource namespace used for list filtering and
// permission checks, e.g. "root.acme".
Namespace string
// Labels is a denormalized snapshot of the owning resource labels so
// notification lists can use label selectors such as "env=prod".
Labels Labels
// Title is the short user-facing summary shown in notification lists.
Title string
// Message is the longer user-facing explanation shown in detail surfaces.
Message string
// ActionUrl is the relative route for the suggested action, e.g.
// "/connections/cxn_...?action=reauth"; it is only returned to actors that
// satisfy ActionPermissions.
ActionUrl *string
// ViewPermissions are the stored permissions an actor must satisfy before
// seeing the notification, usually a resource "get" permission.
ViewPermissions NotificationPermissions
// ActionPermissions are the stored permissions an actor must satisfy before
// receiving ActionUrl/can_action=true, usually a resource "update"
// permission.
ActionPermissions NotificationPermissions
// Metadata is producer-specific structured context for debugging or UI
// hints, e.g. {"target_version": 3, "requires_reauth": true}.
Metadata NotificationMetadata
// ResolvedAt is set when State transitions to resolved.
ResolvedAt *time.Time
// CreatedAt is when the notification row was first inserted.
CreatedAt time.Time
// UpdatedAt is when the notification was last changed or reactivated.
UpdatedAt time.Time
// DeletedAt is reserved for soft deletion; non-nil rows are excluded.
DeletedAt *time.Time
}
func (*Notification) GetId ¶
func (n *Notification) GetId() apid.ID
func (*Notification) GetNamespace ¶
func (n *Notification) GetNamespace() string
func (*Notification) Validate ¶
func (n *Notification) Validate() error
type NotificationLevel ¶
type NotificationLevel string
const ( NotificationLevelInfo NotificationLevel = "info" NotificationLevelWarning NotificationLevel = "warning" NotificationLevelError NotificationLevel = "error" )
type NotificationMetadata ¶
func (*NotificationMetadata) Scan ¶
func (m *NotificationMetadata) Scan(value interface{}) error
type NotificationPermissions ¶
type NotificationPermissions []aschema.Permission
func (*NotificationPermissions) Scan ¶
func (p *NotificationPermissions) Scan(value interface{}) error
type NotificationState ¶
type NotificationState string
const ( NotificationStateActive NotificationState = "active" NotificationStateResolved NotificationState = "resolved" )
type NotificationUpsert ¶
type OAuth2Token ¶
type OAuth2Token struct {
Id apid.ID
ConnectionId apid.ID // Foreign key to Connection; not enforced by database
RefreshedFromId *apid.ID
EncryptedRefreshToken encfield.EncryptedField
EncryptedAccessToken encfield.EncryptedField
AccessTokenExpiresAt *time.Time
Scopes string
RequestedScopes string
CreatedByActorId *apid.ID // Actor who initiated this token (carried forward on refresh)
CreatedAt time.Time
EncryptedAt *time.Time
DeletedAt *time.Time
}
func (*OAuth2Token) IsAccessTokenExpired ¶
func (t *OAuth2Token) IsAccessTokenExpired(ctx context.Context) bool
func (*OAuth2Token) Validate ¶
func (t *OAuth2Token) Validate() error
type OAuth2TokenWithConnection ¶
type OAuth2TokenWithConnection struct {
Token OAuth2Token
Connection Connection
}
type ParentCarryForward ¶
ParentCarryForward bundles a parent's resource-type token with the parent's stored labels for use with ApplyParentCarryForward.
type Permissions ¶
type Permissions []aschema.Permission
Permissions is a custom type for a slice of permissions. The values are serlized to json.
func (*Permissions) Scan ¶
func (p *Permissions) Scan(value interface{}) error
Scan implements the sql.Scanner interface for Permissions
type RateLimit ¶
type RateLimit struct {
Id apid.ID
Namespace string
Name scommon.ResourceName
Definition rlschema.RateLimit
Labels Labels
Annotations Annotations
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
}
RateLimit is the database envelope for a rate-limit resource. Definition holds the JSON-serialised configuration (mode, selector, bucket, algorithm).
func (*RateLimit) GetNamespace ¶
type RateLimitOrderByField ¶
type RateLimitOrderByField string
const ( RateLimitOrderByCreatedAt RateLimitOrderByField = "created_at" RateLimitOrderByUpdatedAt RateLimitOrderByField = "updated_at" RateLimitOrderByNamespace RateLimitOrderByField = "namespace" )
type ReEncryptedFieldUpdate ¶
type ReEncryptedFieldUpdate struct {
Table string
PrimaryKeyCols []string
PrimaryKeyValues []any
FieldColumn string
NewValue encfield.EncryptedField
}
ReEncryptedFieldUpdate carries the data to update a single encrypted field after re-encryption.
type ReEncryptionTarget ¶
type ReEncryptionTarget struct {
Table string
PrimaryKeyCols []string // column names in PK order (from registration)
PrimaryKeyValues []any // values in PK column order
FieldColumn string // which encrypted column
EncryptedFieldValue encfield.EncryptedField // current value (contains the active DEK ID)
TargetDataEncryptionKeyId apid.ID // target DEK for the namespace
}
ReEncryptionTarget represents one encrypted field on one row that needs re-encryption.
type ResourceSearcher ¶
type ResourceSearcher interface {
SearchResources(ctx context.Context, params SearchResourcesParams) (SearchResourcesResult, error)
}
ResourceSearcher is the replaceable database-facing search contract. The live database service implements it with bounded provider-specific queries; callers can substitute a projection-backed implementation later without changing the Admin API contract.
type SearchLabelMatch ¶
type SearchResource ¶
type SearchResource struct {
ResourceType SearchResourceType
ResourceID string
Name string
Namespace string
Labels Labels
MatchedLabels []SearchLabelMatch
UpdatedAt time.Time
MatchRank int
}
type SearchResourceType ¶
type SearchResourceType string
SearchResourceType identifies a durable resource supported by the Admin UI command palette. Request events and task/workflow monitoring records are intentionally excluded because they are not stored in the primary database.
const ( SearchResourceTypeActor SearchResourceType = "actor" SearchResourceTypeConnection SearchResourceType = "connection" SearchResourceTypeConnector SearchResourceType = "connector" SearchResourceTypeNamespace SearchResourceType = "namespace" SearchResourceTypeKey SearchResourceType = "key" SearchResourceTypeRateLimit SearchResourceType = "rate_limit" )
func SearchResourceTypes ¶
func SearchResourceTypes() []SearchResourceType
type SearchResourcesParams ¶
type SearchResourcesParams struct {
ResourceType SearchResourceType
Query string
LabelSelector string
NamespaceMatchers []string
Limit int
}
type SearchResourcesResult ¶
type SearchResourcesResult struct {
Items []SearchResource
Truncated bool
}
type UsedNonce ¶
UsedNonce represents a onetime use value (UUID) that has already been used in the system and cannot be used again. When used outside the system, nonces should also use some sort of expiry mechanism such that when they are used there is a known time that they must be retained until so that the list of used nonces doesn't grow infinitely.
Source Files
¶
- actor.go
- annotations.go
- api_key_credential.go
- connection.go
- connection_probe_outcome.go
- connector.go
- connector_definition_version.go
- connector_with_definition.go
- data_encryption_key.go
- error.go
- interface.go
- key.go
- label_selector.go
- labels.go
- labels_propagate.go
- migrate.go
- namespace.go
- notification.go
- oauth2_token.go
- purge.go
- rate_limit.go
- reencrypt_registry.go
- resource_search.go
- service.go
- test_db.go
- used_nonce.go
- util.go