client

package
v0.27.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 55 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DefaultUserLimit is the maximum number of users allowed when no
	// license-derived user-limit provider is configured.
	DefaultUserLimit = 100

	// DefaultDeviceLimit is the maximum number of devices allowed when no
	// license-derived device-limit provider is configured.
	DefaultDeviceLimit = 100
)
View Source
const (

	// DefaultGroupPageSize is the page size used when a caller does not ask for one.
	DefaultGroupPageSize = 50

	// MaxGroupPageSize matches the ceiling the auth providers enforce, which is set by the
	// smallest page any of the identity providers will serve in a single request.
	MaxGroupPageSize = 100
)
View Source
const (

	// AccountNotActiveMessage is what a user denied access by their lifecycle status is told. It does not reveal
	// the reason, which only administrators see.
	AccountNotActiveMessage = "You are not authorized to access this application. Contact your administrator."
)

Variables

View Source
var (
	// ErrLocalAuthUserExists is returned when creating a local auth user whose email is already taken.
	ErrLocalAuthUserExists = errors.New("local auth user already exists")

	// ErrBootstrapLocalAuthUserLimit is returned when bootstrap tries to create another account.
	ErrBootstrapLocalAuthUserLimit = errors.New("bootstrap can only create one local account; sign in with the existing account to continue setup")
)
View Source
var (
	// ErrSCIMConnectionNotFound reports that no SCIM connection has the requested ID, or that none exists.
	ErrSCIMConnectionNotFound = errors.New("SCIM connection not found")
	// ErrMultipleSCIMConnections reports that more than one SCIM connection exists, which only one may. No SCIM request
	// is served then, because none can tell which connection it is for.
	ErrMultipleSCIMConnections = errors.New("more than one SCIM connection exists")
	// ErrSCIMManagedGroupData reports an attempt to delete the group data of an auth provider whose group ID prefix the
	// SCIM connection of another auth provider manages.
	ErrSCIMManagedGroupData = errors.New("the group data is managed by a SCIM connection")
	// ErrSCIMConnectionHasToken reports an attempt to issue the first bearer token of a connection that has one.
	ErrSCIMConnectionHasToken = errors.New("the SCIM connection already has a token")
	// ErrSCIMGroupDeletionInProgress reports an attempt to enforce SCIM while another deletion of unreferenced groups
	// holds marks for deletion.
	ErrSCIMGroupDeletionInProgress = errors.New("another deletion of unreferenced groups is in progress")
)
View Source
var (
	ErrClaudeCredentialRevoked = errors.New("the Claude session API key has been revoked")
)
View Source
var (
	// ErrGroupRoleAssignmentNotFound is returned when a group role assignment is not found.
	ErrGroupRoleAssignmentNotFound = errors.New("group role assignment not found")
)
View Source
var (
	// ErrInvalidAPIKey reports that a presented API key is not a valid credential: it is malformed, unknown, wrong,
	// expired, or revoked. ValidateAPIKey returns other errors when it could not read the key or its user.
	ErrInvalidAPIKey = errors.New("invalid API key")
)
View Source
var (
	ErrInvalidOrExpiredDeviceCode = errors.New("invalid or expired device code")
)

Functions

func IsUniqueViolation added in v0.27.0

func IsUniqueViolation(err error) bool

IsUniqueViolation reports whether err is a unique constraint violation from PostgreSQL or SQLite. Neither driver translates them to gorm.ErrDuplicatedKey unless gorm is configured to. PostgreSQL's messages depend on the database's language, so its error code is compared instead.

func NormalizeEmail added in v0.24.0

func NormalizeEmail(email string) string

NormalizeEmail lowercases and trims an email address so that logins are case-insensitive.

func ParseAPIKey added in v0.16.0

func ParseAPIKey(key string) (prefix string, userID uint, keyID uint, secret string, err error)

ParseAPIKey parses an API key string and extracts its components. Returns prefix, userID, keyID, secret, and an error if the format is invalid.

func ParseDeviceEnrollmentCredential added in v0.24.0

func ParseDeviceEnrollmentCredential(credential string) (configurationID, keyID uint, secret string, err error)

ParseDeviceEnrollmentCredential extracts the configuration ID, key ID, and secret from an ode1-<configuration_id>-<key_id>-<secret> credential.

func ParseRedactedAPIKey added in v0.26.0

func ParseRedactedAPIKey(key string) (userID uint, keyID uint, err error)

ParseRedactedAPIKey extracts the owner and key IDs from the non-secret API key prefix emitted by nanobot audit logs. Nanobot retains the first three hyphen-delimited components or 12 characters, whichever is longer, so short numeric components can be followed by a small fragment of the redacted secret. Full bearer tokens are deliberately rejected.

func ValidateAuditLogOptions added in v0.24.0

func ValidateAuditLogOptions(opts MCPAuditLogOptions, sources []types2.AuditLogSourceType) error

ValidateAuditLogOptions verifies source selection, source-specific filter compatibility, and sort parameters. If sources is empty, validation uses opts.SourceTypes and applies the MCP-only default when that field is also empty. Validation does not perform any authorization checks; callers must authorize the selected sources separately.

Types

type APIKeyListOptions added in v0.26.0

type APIKeyListOptions struct {
	ShowRevoked bool
}

APIKeyListOptions controls whether retained revoked keys are included.

type AlreadyExistsError added in v0.5.0

type AlreadyExistsError struct {
	// contains filtered or unexported fields
}

func (*AlreadyExistsError) Error added in v0.5.0

func (e *AlreadyExistsError) Error() string

type AuthProviderGroupData added in v0.27.0

type AuthProviderGroupData struct {
	// Groups are the provider's groups.
	Groups []SCIMProviderGroup
	// MembershipCount is the number of memberships in groups with the provider's group ID prefix.
	MembershipCount int64
	// RoleAssignmentGroupIDs are the group IDs with the provider's group ID prefix that a group role assignment
	// names.
	RoleAssignmentGroupIDs []string
}

AuthProviderGroupData is the group data of an auth provider in the gateway database.

func (AuthProviderGroupData) Empty added in v0.27.0

func (d AuthProviderGroupData) Empty() bool

Empty reports whether the auth provider has no group data at all.

type AuthProviderRef added in v0.27.0

type AuthProviderRef struct {
	Namespace string
	Name      string
}

AuthProviderRef identifies an auth provider.

func (AuthProviderRef) String added in v0.27.0

func (r AuthProviderRef) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, db *db.DB, storageClient kclient.Client, encryptionConfig *encryptionconfig.EncryptionConfiguration, mcpOAuthTokenTrigger func(context.Context, string) error, ownerEmails, adminEmails []string, auditLogPersistenceInterval time.Duration, auditLogBatchSize, auditLogRetentionDays, llmAuditLogRetentionDays, deviceScanRetentionDays int, llmAuditEnabled bool) *Client

func (*Client) ActivateLocalAuthUser added in v0.26.0

func (c *Client) ActivateLocalAuthUser(ctx context.Context, setupTokenHash, sessionID string, expiresAt time.Time) (*types.LocalAuthUser, error)

ActivateLocalAuthUser validates a setup token and creates a restricted session. The token stays usable until the password is set, so an interrupted setup can be resumed from the same link.

func (*Client) ActiveUserCountByDate added in v0.26.0

func (c *Client) ActiveUserCountByDate(ctx context.Context, start, end time.Time) (int64, error)

func (*Client) ActiveUsersByDate added in v0.7.1

func (c *Client) ActiveUsersByDate(ctx context.Context, start, end time.Time) ([]types.User, error)

func (*Client) ActivitiesByUser added in v0.7.1

func (c *Client) ActivitiesByUser(ctx context.Context, userID string, start, end time.Time) ([]types.APIActivity, error)

func (*Client) AddActivityForToday added in v0.7.1

func (c *Client) AddActivityForToday(ctx context.Context, userID string) error

func (*Client) AuthProviderGroupData added in v0.27.0

func (c *Client) AuthProviderGroupData(ctx context.Context, namespace, name, groupIDPrefix string) (*AuthProviderGroupData, error)

AuthProviderGroupData returns the group data of an auth provider: its groups, and the memberships and group role assignments of group IDs with its group ID prefix. Auth provider cleanup deletes exactly this data.

func (*Client) AuthProviderVerificationActive added in v0.26.0

func (c *Client) AuthProviderVerificationActive(ctx context.Context, id string) (bool, error)

AuthProviderVerificationActive reports whether this staged-provider verification is still open. It is possession-based because it guards the return leg of the OAuth round trip, where the caller is the replacement provider's identity rather than the owner who started the switch. Use AuthProviderVerificationStartableBy for the outbound leg.

func (*Client) AuthProviderVerificationStartableBy added in v0.26.0

func (c *Client) AuthProviderVerificationStartableBy(ctx context.Context, id string, userID uint) (bool, error)

AuthProviderVerificationStartableBy reports whether userID may open the login for this verification. A verification belongs to the owner who started the switch, so another signed-in user holding the ID must not be able to use it.

func (*Client) AuthenticateSCIMConnection added in v0.27.0

func (c *Client) AuthenticateSCIMConnection(ctx context.Context, token string) (*types.SCIMConnection, error)

AuthenticateSCIMConnection returns the SCIM connection if token is its current bearer token or its previous one, while that token is still accepted. There is at most one connection, which serves every SCIM request. It returns ErrSCIMConnectionNotFound when there is none, ErrMultipleSCIMConnections when there is more than one, and *SCIMAuthenticationError for any other token, including an expired one, every token presented to a connection that has none, and one issued for an earlier connection.

func (*Client) AuthorizeTokenRequestByDeviceCode added in v0.26.0

func (c *Client) AuthorizeTokenRequestByDeviceCode(ctx context.Context, userID uint, code string) error

AuthorizeTokenRequestByDeviceCode consumes an unexpired device code and atomically creates and publishes an API key for the authenticated user.

func (*Client) CheckCredentialOwner added in v0.27.0

func (c *Client) CheckCredentialOwner(ctx context.Context, userID uint) error

CheckCredentialOwner returns nil unless issuing a credential to the user must be refused. It reads the user's current state, and returns a *UserAccessDeniedError if the user is disabled or deleted, and a *UserAccessLookupError if the state could not be read. A user ID with no row is left to the admission check, which denies every use of a credential issued for it.

func (*Client) CheckSCIMEnforceActor added in v0.27.0

func (c *Client) CheckSCIMEnforceActor(ctx context.Context, conn *types.SCIMConnection, actor SCIMEnforceActor) (SCIMEnforceActorProblem, error)

CheckSCIMEnforceActor returns why the actor may not enforce the connection, or an empty problem when they may.

func (*Client) ClaimSCIMGroupSubjectCleanups added in v0.27.0

func (c *Client) ClaimSCIMGroupSubjectCleanups(ctx context.Context, limit int) ([]types.SCIMGroupSubjectCleanup, error)

ClaimSCIMGroupSubjectCleanups claims, for this replica, up to limit cleanups of the subjects of deleted groups that no replica is running, and returns them. The caller completes or fails each one.

func (*Client) ClaudeEnvironment added in v0.27.0

func (c *Client) ClaudeEnvironment(ctx context.Context, id string) (*types.ClaudeEnvironment, error)

func (*Client) ClaudeEnvironments added in v0.27.0

func (c *Client) ClaudeEnvironments(ctx context.Context) ([]types.ClaudeEnvironment, error)

func (*Client) ClaudeOrganizationAccount added in v0.27.0

func (c *Client) ClaudeOrganizationAccount(ctx context.Context, organization, account string) (*types.ClaudeOrganizationAccount, error)

func (*Client) ClaudeOrganizationAccountForUser added in v0.27.0

func (c *Client) ClaudeOrganizationAccountForUser(ctx context.Context, organization, user string) (*types.ClaudeOrganizationAccount, error)

func (*Client) ClaudeOrganizationAccounts added in v0.27.0

func (c *Client) ClaudeOrganizationAccounts(ctx context.Context, organization string) ([]types.ClaudeOrganizationAccount, error)

func (*Client) ClaudeWorkOrderSubmitted added in v0.27.0

func (c *Client) ClaudeWorkOrderSubmitted(ctx context.Context, name string) (bool, error)

func (*Client) CleanupExpiredMCPOAuthPendingStates added in v0.17.0

func (c *Client) CleanupExpiredMCPOAuthPendingStates(ctx context.Context, olderThan time.Duration) error

func (*Client) ClearSCIMGroupDeletionMarks added in v0.27.0

func (c *Client) ClearSCIMGroupDeletionMarks(ctx context.Context, connectionID, runID string) error

ClearSCIMGroupDeletionMarks unmarks the groups that a deletion marked and still holds, so that references to them are accepted again. It is used when the deletion does not go ahead.

func (*Client) ClearTempUserCache added in v0.13.0

func (c *Client) ClearTempUserCache(ctx context.Context) error

ClearTempUserCache removes all cached temporary users from the database.

func (*Client) Close

func (c *Client) Close() error

func (*Client) CompleteLocalAuthUserPasswordChange added in v0.26.0

func (c *Client) CompleteLocalAuthUserPasswordChange(ctx context.Context, id uint, passwordHash, currentSessionID string) error

CompleteLocalAuthUserPasswordChange atomically completes a required password change. The session must still exist and the user must still be pending, so only the first of them sets the password.

func (*Client) CompleteSCIMGroupSubjectCleanup added in v0.27.0

func (c *Client) CompleteSCIMGroupSubjectCleanup(ctx context.Context, groupID string) error

CompleteSCIMGroupSubjectCleanup records that the subjects of a deleted group were removed.

func (*Client) CopyMCPOAuthTokens added in v0.26.0

func (c *Client) CopyMCPOAuthTokens(ctx context.Context, userID, sourceID, targetID string) error

CopyMCPOAuthTokens preserves a migrated connection's upstream authorization. Existing destination tokens take precedence, including tokens refreshed after a partially completed migration.

func (*Client) CreateAPIKey added in v0.16.0

func (c *Client) CreateAPIKey(ctx context.Context, userID uint, name, description string, expiresAt *time.Time, scopes types.APIKeyScopes) (*types.APIKeyCreateResponse, error)

CreateAPIKey generates a new API key for the given user. Returns the full key only once in the response.

func (*Client) CreateAPIKeyFromSetupTokenRequest added in v0.26.0

func (c *Client) CreateAPIKeyFromSetupTokenRequest(ctx context.Context, userID uint, tr *types.TokenRequest) (*types.APIKeyCreateResponse, error)

CreateAPIKeyFromSetupTokenRequest creates an API key from a token request.

func (*Client) CreateBootstrapLocalAuthUser added in v0.26.0

func (c *Client) CreateBootstrapLocalAuthUser(ctx context.Context, email, passwordHash string, requirePasswordChange bool) (*types.LocalAuthUser, error)

CreateBootstrapLocalAuthUser only creates an account when no local accounts exist.

func (*Client) CreateDeviceEnrollmentKey added in v0.24.0

func (c *Client) CreateDeviceEnrollmentKey(ctx context.Context, configurationID, createdBy uint, name string, expiresAt *time.Time) (*types.DeviceEnrollmentKeyCreateResponse, error)

CreateDeviceEnrollmentKey attaches an additional enrollment key to a configuration. Existing keys and enrolled devices are untouched.

func (*Client) CreateDeviceTokenRequest added in v0.26.0

func (c *Client) CreateDeviceTokenRequest(ctx context.Context, tr *types.TokenRequest) (string, error)

CreateDeviceTokenRequest initializes and persists a device login request. Only the formatted device code is returned; the database stores its digest.

func (*Client) CreateGroupRoleAssignment added in v0.15.0

func (c *Client) CreateGroupRoleAssignment(ctx context.Context, groupName string, role types2.Role, description string) (*types.GroupRoleAssignment, error)

CreateGroupRoleAssignment creates a new group role assignment.

func (*Client) CreateImage added in v0.7.0

func (c *Client) CreateImage(ctx context.Context, data []byte, mimeType string) (*types.Image, error)

CreateImage stores a new image in the database

func (*Client) CreateInitialLocalAuthUser added in v0.26.0

func (c *Client) CreateInitialLocalAuthUser(ctx context.Context, email, passwordHash, setupTokenHash string, setupTokenExpiresAt time.Time) (*types.LocalAuthUser, error)

CreateInitialLocalAuthUser creates a user that can only be claimed with a setup token. Only the token's hash is persisted, and password completion revokes it.

func (*Client) CreateLocalAuthSession added in v0.24.0

func (c *Client) CreateLocalAuthSession(ctx context.Context, id string, userID uint, expiresAt time.Time) error

CreateLocalAuthSession records a session for the given user. The ID must be a hash of the token that is handed to the browser, never the token itself.

func (*Client) CreateLocalAuthUser added in v0.24.0

func (c *Client) CreateLocalAuthUser(ctx context.Context, email, passwordHash string, requirePasswordChange bool) (*types.LocalAuthUser, error)

CreateLocalAuthUser creates a new local auth user. The password must already be hashed.

func (*Client) CreateMCPOAuthPendingState added in v0.17.0

func (c *Client) CreateMCPOAuthPendingState(ctx context.Context, userID, mcpID, mcpURL, tunnelName, oauthAuthRequestID, state, verifier, resourceURL string, oauthConf *oauth2.Config) error

func (*Client) CreateMDMConfiguration added in v0.24.0

func (c *Client) CreateMDMConfiguration(ctx context.Context, createdBy uint, configuration *types.MDMConfiguration) (*types.MDMConfiguration, error)

CreateMDMConfiguration creates a configuration and atomically persists any rendered artifact content. The first configuration becomes the default.

func (*Client) CreateSCIMConnection added in v0.27.0

func (c *Client) CreateSCIMConnection(ctx context.Context, opts CreateSCIMConnectionOptions) (*types.SCIMConnection, string, error)

CreateSCIMConnection creates the SCIM connection of an auth provider in the connected state. From this moment SCIM replaces login-time directory synchronization for the provider, and there is no way back. The adapter is chosen by the auth provider's name, and recorded on the connection.

When opts.IssueToken is set, it also returns the connection's bearer token, which is not stored and cannot be retrieved again.

func (*Client) CreateSCIMGroup added in v0.27.0

func (c *Client) CreateSCIMGroup(ctx context.Context, conn *types.SCIMConnection, input SCIMGroupInput) (*SCIMGroup, error)

CreateSCIMGroup binds a pushed group to the one unbound group of the connection's auth provider with the same normalized name, keeping that group's ID, or creates a group when there is none. The pushed members replace the group's memberships in the same transaction: cached members that the identity provider did not push are removed, and members that remain are not touched.

func (*Client) CreateSCIMUser added in v0.27.0

func (c *Client) CreateSCIMUser(ctx context.Context, conn *types.SCIMConnection, input SCIMUserInput, opts SCIMUserCreateOptions) (*SCIMUser, error)

CreateSCIMUser provisions a SCIM user. It binds the user to the existing user whose identity for the connection's exact auth provider stores the same native user ID, and otherwise creates a user and identity through the seat-checked path. Email is never evidence of identity.

A user that was deleted in Obot is never restored: provisioning the same person again creates a new, empty account and relinks the identity to it.

func (*Client) CreateServiceAccountAPIKey added in v0.21.0

func (c *Client) CreateServiceAccountAPIKey(ctx context.Context, serviceAccountName string, now time.Time) (*types.ServiceAccountAPIKey, error)

func (*Client) CreateTokenRequest added in v0.13.0

func (c *Client) CreateTokenRequest(ctx context.Context, tr *types.TokenRequest) error

CreateTokenRequest creates a new token request in the database.

func (*Client) CreateTokenRequestState added in v0.26.0

func (c *Client) CreateTokenRequestState(ctx context.Context, id string) (string, error)

CreateTokenRequestState creates and stores a fresh OAuth state for a setup token request.

func (*Client) DeleteAllLocalAuthSessions added in v0.24.0

func (c *Client) DeleteAllLocalAuthSessions(ctx context.Context) error

DeleteAllLocalAuthSessions signs every local user out. It is used when the provider is deconfigured, so that reconfiguring it later doesn't bring old sessions back to life.

func (*Client) DeleteAllServiceAccountAPIKeys added in v0.21.0

func (c *Client) DeleteAllServiceAccountAPIKeys(ctx context.Context, serviceAccountName string) error

func (*Client) DeleteAuthProviderGroupData added in v0.25.2

func (c *Client) DeleteAuthProviderGroupData(ctx context.Context, authProviderNamespace, authProviderName, groupIDPrefix string) error

DeleteAuthProviderGroupData removes all gateway-database state for groups belonging to a deconfigured auth provider. It is transactional and idempotent so controller retries are safe.

It deletes nothing while a SCIM connection owns the data. It returns ErrSCIMManagedGroupData when the connection of another auth provider manages the group ID prefix: the identity provider holds the IDs of those groups, and nothing could rebuild them. It returns an error to retry when the provider's own connection still exists, which deconfiguring the provider deletes first.

func (*Client) DeleteAuthProviderSCIMConnection added in v0.27.0

func (c *Client) DeleteAuthProviderSCIMConnection(ctx context.Context, provider AuthProviderRef) (*DeletedSCIMConnection, error)

DeleteAuthProviderSCIMConnection deletes the SCIM connection of an auth provider that is being deconfigured, with all of its SCIM data and the provider's group data: its groups, and the memberships and group role assignments of group IDs with its group ID prefix. The provider's users and identities are kept. Users that SCIM disabled stay disabled, with their API keys and agents, until an administrator enables them: enabling them here would give their API keys, and the agents that mint keys for them, access again without any sign-in. Configuring the provider again starts SCIM over, with a new connection that the identity provider pushes its users and groups to again.

It records no reconcile events: the auth provider cleanup removes the provider's groups from access policies and reconciles every user with an identity of the provider. It returns nil, and changes nothing, when the provider has no connection, so that a retried deconfiguration is safe.

func (*Client) DeleteAuthToken added in v0.26.0

func (c *Client) DeleteAuthToken(ctx context.Context, userID uint, id string) error

DeleteAuthToken deletes an auth token owned by a user.

func (*Client) DeleteClaudeEnvironment added in v0.27.0

func (c *Client) DeleteClaudeEnvironment(ctx context.Context, id string) error

func (*Client) DeleteCredential added in v0.23.0

func (c *Client) DeleteCredential(ctx context.Context, context, name string) (bool, error)

DeleteCredential deletes a credential if it exists and returns whether a credential was deleted.

func (*Client) DeleteDeviceEnrollmentKey added in v0.24.0

func (c *Client) DeleteDeviceEnrollmentKey(ctx context.Context, configurationID, id uint) error

DeleteDeviceEnrollmentKey removes a single enrollment key. It only stops that key from enrolling new devices; already-enrolled devices are unaffected. Scoped to the configuration so a mismatched path can't delete another configuration's key. Idempotent: deleting a key that doesn't exist succeeds.

func (*Client) DeleteDeviceScan added in v0.22.0

func (c *Client) DeleteDeviceScan(ctx context.Context, id uint) error

DeleteDeviceScan removes a scan and its child rows. Idempotent: returns nil when no scan with that id exists.

func (*Client) DeleteExpiredLocalAuthSessions added in v0.24.0

func (c *Client) DeleteExpiredLocalAuthSessions(ctx context.Context) error

DeleteExpiredLocalAuthSessions removes sessions that are past their expiration.

func (*Client) DeleteExpiredServiceAccountAPIKeys added in v0.21.0

func (c *Client) DeleteExpiredServiceAccountAPIKeys(ctx context.Context, serviceAccountName string, now time.Time) error

func (*Client) DeleteGroupRoleAssignment added in v0.15.0

func (c *Client) DeleteGroupRoleAssignment(ctx context.Context, groupName string) error

DeleteGroupRoleAssignment deletes a group role assignment by group name.

func (*Client) DeleteHostedAgentRecords added in v0.27.0

func (c *Client) DeleteHostedAgentRecords(ctx context.Context) error

DeleteHostedAgentRecords runs only after the legacy runtime has been removed. These kinm kinds no longer have API endpoints, so drop their tables directly.

func (*Client) DeleteImage added in v0.7.0

func (c *Client) DeleteImage(ctx context.Context, id string) error

DeleteImage removes an image from the database

func (*Client) DeleteLocalAuthSession added in v0.24.0

func (c *Client) DeleteLocalAuthSession(ctx context.Context, id string) error

func (*Client) DeleteLocalAuthSessionsForEmail added in v0.24.0

func (c *Client) DeleteLocalAuthSessionsForEmail(ctx context.Context, email, exceptSessionID string) error

DeleteLocalAuthSessionsForEmail signs the local user with the given email out of all sessions. If exceptSessionID is non-empty, that one session is kept (used to preserve the caller's own session when they log out everywhere else).

func (*Client) DeleteLocalAuthUser added in v0.24.0

func (c *Client) DeleteLocalAuthUser(ctx context.Context, id uint) error

func (*Client) DeleteMCPOAuthPendingState added in v0.17.0

func (c *Client) DeleteMCPOAuthPendingState(ctx context.Context, hashedState string) error

func (*Client) DeleteMCPOAuthTokenForAllUsers added in v0.8.0

func (c *Client) DeleteMCPOAuthTokenForAllUsers(ctx context.Context, mcpID string) error

func (*Client) DeleteMCPOAuthTokenForURL added in v0.15.0

func (c *Client) DeleteMCPOAuthTokenForURL(ctx context.Context, userID, mcpID, mcpURL string) error

func (*Client) DeleteMCPOAuthTokens added in v0.15.0

func (c *Client) DeleteMCPOAuthTokens(ctx context.Context, userID, mcpID string) error

func (*Client) DeleteMDMConfiguration added in v0.24.0

func (c *Client) DeleteMDMConfiguration(ctx context.Context, id uint) error

DeleteMDMConfiguration removes a configuration and its enrollment keys. Devices enrolled into it are intentionally preserved (not deleted).

func (*Client) DeleteMarkedSCIMGroups added in v0.27.0

func (c *Client) DeleteMarkedSCIMGroups(ctx context.Context, connectionID, runID string, referenced map[string]struct{}) ([]string, error)

DeleteMarkedSCIMGroups finishes a deletion of unreferenced groups that MarkUnreferencedSCIMGroups started as the run runID, and returns the IDs of the groups it deleted. referenced holds the IDs of the groups that anything references, read after MarkUnreferencedSCIMGroups returned.

A marked group that gained a reference in between is unmarked and kept, and so is one that SCIM bound or another deletion took over. The rest of the run's groups are deleted with their memberships. They grant nothing, so their deletion records no reconcile event, and triggers no cleanup of the resources of their former members.

func (*Client) DeleteProperty added in v0.23.0

func (c *Client) DeleteProperty(ctx context.Context, key string) error

func (*Client) DeleteSCIMGroup added in v0.27.0

func (c *Client) DeleteSCIMGroup(ctx context.Context, conn *types.SCIMConnection, id string) error

DeleteSCIMGroup retires a group's binding and removes its memberships. The retired binding stays, so that its SCIM ID is never reused.

While SCIM is not enforced, the group and every reference to it remain, and the group becomes unbound again: pushing it later under the same name binds it under a new SCIM ID and restores its members. Once SCIM is enforced, the group is deleted as well, with its group role assignments, so that a group pushed later under the same name gets none of what the deleted group was granted. Its subjects in access policies are removed by a cleanup that ClaimSCIMGroupSubjectCleanups hands out.

func (*Client) DeleteServiceAccountAPIKeyByID added in v0.21.0

func (c *Client) DeleteServiceAccountAPIKeyByID(ctx context.Context, id uint) error

func (*Client) DeleteSessionsForUser added in v0.8.0

func (c *Client) DeleteSessionsForUser(ctx context.Context, storageClient kclient.Client, identities []types.Identity, sessionID, localSessionID string) error

DeleteSessionsForUser deletes the user's sessions across all of their identities. When keepSessionID / keepLocalSessionID are non-empty, the caller's current session is preserved (the "log out everywhere else" flow); when both are empty, every session is deleted (e.g. when the user is being deleted).

func (*Client) DeleteStagedSCIMConnection added in v0.27.0

func (c *Client) DeleteStagedSCIMConnection(ctx context.Context, provider AuthProviderRef) (*DeletedSCIMConnection, error)

DeleteStagedSCIMConnection deletes the SCIM connection that staging an auth provider without directory credentials created, as DeleteAuthProviderSCIMConnection does, when the staging is discarded. It deletes nothing, and returns nil, unless the provider holds a staged credential and no credential in its own or the generic auth provider context: deleting the connection of the configured provider would stop its sign-ins.

func (*Client) DeleteUser added in v0.5.0

func (c *Client) DeleteUser(ctx context.Context, userID string) error

func (*Client) DeviceCount added in v0.25.0

func (c *Client) DeviceCount(ctx context.Context) (int64, error)

DeviceCount returns the total number of enrolled devices.

func (*Client) DeviceScanCount added in v0.26.0

func (c *Client) DeviceScanCount(ctx context.Context, start, end time.Time) (int64, error)

func (*Client) EgressAuditEnvironments added in v0.27.0

func (c *Client) EgressAuditEnvironments(ctx context.Context) (map[string]string, error)

EgressAuditEnvironments exposes names without loading configuration or secrets.

func (*Client) EnableUser added in v0.27.0

func (c *Client) EnableUser(ctx context.Context, userID uint) (*types.User, error)

EnableUser restores the access of a disabled user, as an administrator decides to, with the same ID and data. It is refused with *SCIMManagedUserError while SCIM manages the user's access: while the user has a SCIM binding, or an identity of an auth provider that has a SCIM connection, whose identity provider decides whom it provisions. A deleted user cannot be enabled, and enabling a user who is not disabled changes nothing.

func (*Client) EncryptIdentities added in v0.8.0

func (c *Client) EncryptIdentities(ctx context.Context, force bool) error

EncryptIdentities will pull all identities out of the database and ensure they are encrypted.

func (*Client) EncryptUsers added in v0.13.0

func (c *Client) EncryptUsers(ctx context.Context, force bool) error

EncryptUsers will pull all users out of the database and ensure they are encrypted.

func (*Client) EnforceSCIMConnection added in v0.27.0

func (c *Client) EnforceSCIMConnection(ctx context.Context, id string, opts EnforceSCIMOptions) (*EnforceSCIMResult, error)

EnforceSCIMConnection requires a SCIM binding for sign-in with the connection's auth provider, permanently.

The unreferenced groups must already be marked for deletion by the run opts.RunID, and opts.ReferencedGroupIDs read after MarkUnreferencedSCIMGroups returned. A marked group that gained a reference in between is unmarked and kept, and only the groups that run still holds marks on are deleted.

Enforcing is refused with *SCIMEnforceBlockedError while a referenced group of the provider is unbound, because the memberships of a group the identity provider never pushes would be frozen forever, or while the actor could not be known to sign in afterwards. A refused Enforce clears the connection's marks for deletion. It is refused with ErrSCIMGroupDeletionInProgress, and changes nothing, while another deletion holds marks that have not expired.

Otherwise, in one transaction, it disables every live user of the provider that the connection has not provisioned, deletes the groups still marked for deletion with their memberships, and records the enforcement. It changes no memberships of the groups it keeps, deletes no user, and records no reconcile event: the groups it deletes grant nothing.

func (*Client) EnforcementDecisionCount added in v0.26.0

func (c *Client) EnforcementDecisionCount(ctx context.Context, start, end time.Time) (int64, error)

func (*Client) EnrollDevice added in v0.24.0

func (c *Client) EnrollDevice(ctx context.Context, in DeviceEnrollment, deviceLimit DeviceLimit) (*types.Device, error)

EnrollDevice registers a device's identity key trust-on-first-use and returns the device. Re-enrollment semantics keyed on DeviceID:

  • same device, same key -> reactivate and rebind to the configuration
  • same device, different key -> rejected (anti-takeover)
  • new device -> created

func (*Client) EnsureClaudeCredential added in v0.27.0

func (c *Client) EnsureClaudeCredential(ctx context.Context, userID uint, name string, servers []string, expires time.Time) (types.Credential, error)

EnsureClaudeCredential reuses a valid key or atomically replaces an expired key. The caller must verify the session and account under WithClaudeProvisionLock.

func (*Client) EnsureClaudeTagUser added in v0.27.0

func (c *Client) EnsureClaudeTagUser(ctx context.Context, environment *types.ClaudeEnvironment) error

EnsureClaudeTagUser runs under the provisioning lock. Service users have no login identity or verified email, so provider login cannot adopt the account.

func (*Client) EnsureIdentity

func (c *Client) EnsureIdentity(ctx context.Context, id *types.Identity, timezone string, userLimit UserLimit) (*types.User, error)

EnsureIdentity ensures that the given identity exists in the database, and returns the user associated with it. The user gets the explicit role of their email, which ensureIdentityUser applies.

func (*Client) EnsureIdentityWithRole added in v0.5.0

func (c *Client) EnsureIdentityWithRole(ctx context.Context, id *types.Identity, timezone string, role types2.Role, userLimit UserLimit) (*types.User, error)

EnsureIdentityWithRole ensures the given identity exists in the database with the at least the given role, and returns the user associated with it. If the user already exists with a superset of the given role, it will not be updated.

func (*Client) FailSCIMGroupSubjectCleanup added in v0.27.0

func (c *Client) FailSCIMGroupSubjectCleanup(ctx context.Context, groupID string, cause error) error

FailSCIMGroupSubjectCleanup records why removing the subjects of a deleted group failed. The cleanup keeps its claim, so it is retried once the claim expires.

func (*Client) FindIdentitiesForUser added in v0.8.0

func (c *Client) FindIdentitiesForUser(ctx context.Context, userID uint) ([]types.Identity, error)

FindIdentitiesForUser finds all identities for the given user.

func (*Client) FlushEgressAuditLogs added in v0.27.0

func (c *Client) FlushEgressAuditLogs() error

FlushEgressAuditLogs drains queued captures using an independent write context.

func (*Client) GetAPIKey added in v0.16.0

func (c *Client) GetAPIKey(ctx context.Context, userID uint, keyID uint) (*types.APIKey, error)

GetAPIKey retrieves a single API key by ID.

func (*Client) GetAPIKeyByID added in v0.16.0

func (c *Client) GetAPIKeyByID(ctx context.Context, keyID uint) (*types.APIKey, error)

GetAPIKeyByID retrieves an API key by ID without user filtering (for admin use).

func (*Client) GetAuditLogFilterOptions added in v0.8.0

func (c *Client) GetAuditLogFilterOptions(ctx context.Context, option string, opts MCPAuditLogOptions, exclude ...any) ([]string, error)

GetAuditLogFilterOptions returns distinct values for an allowed audit-log filter column under the same source, scope, common-filter, and time constraints used by the list query. The caller must validate option against its public allowlist before calling this method.

func (*Client) GetAuthProviderGroupCleanupUserIDs added in v0.25.2

func (c *Client) GetAuthProviderGroupCleanupUserIDs(ctx context.Context, authProviderNamespace, authProviderName string, afterUserID uint, limit int) ([]uint, error)

GetAuthProviderGroupCleanupUserIDs returns one ordered page of users with an identity from the auth provider. The cursor is exclusive so cleanup progress remains bounded and durable.

func (*Client) GetDeviceByDeviceID added in v0.24.0

func (c *Client) GetDeviceByDeviceID(ctx context.Context, deviceID string) (*types.Device, error)

GetDeviceByDeviceID looks up an enrolled device by its client-computed ID.

func (*Client) GetDeviceClientFleetSummary added in v0.22.0

func (c *Client) GetDeviceClientFleetSummary(ctx context.Context, name string) (*DeviceClientFleetSummary, error)

GetDeviceClientFleetSummary returns the aggregate for a single client name, or gorm.ErrRecordNotFound when that name never appears on any device's latest scan.

func (*Client) GetDeviceScan added in v0.22.0

func (c *Client) GetDeviceScan(ctx context.Context, id uint) (*types.DeviceScan, error)

GetDeviceScan loads a single scan with all children preloaded.

func (*Client) GetDeviceScanStats added in v0.22.0

func (c *Client) GetDeviceScanStats(ctx context.Context, opts DeviceScanStatsOptions) (*DeviceScanStatsResult, error)

GetDeviceScanStats returns the dashboard rollup for a window: the distinct device count and three ranked breakdowns (clients, MCP servers, skills) computed over each device's latest scan in the window. Returns every group; the caller picks any top-N.

func (*Client) GetEgressAuditLog added in v0.27.0

func (c *Client) GetEgressAuditLog(ctx context.Context, id string, auditor bool) (*types.EgressAuditLog, error)

func (*Client) GetEnforcementDecision added in v0.25.0

func (c *Client) GetEnforcementDecision(ctx context.Context, id uint) (*types.EnforcementDecisionLog, error)

func (*Client) GetEnforcementDecisionFilterOptions added in v0.25.0

func (c *Client) GetEnforcementDecisionFilterOptions(ctx context.Context, option string, opts EnforcementDecisionOptions) ([]string, error)

func (*Client) GetEnforcementDecisions added in v0.25.0

func (c *Client) GetEnforcementDecisions(ctx context.Context, opts EnforcementDecisionOptions) ([]types.EnforcementDecisionLog, int64, error)

func (*Client) GetExplicitRoleEmails added in v0.13.0

func (c *Client) GetExplicitRoleEmails() map[string]types2.Role

GetExplicitRoleEmails returns a copy of all emails with explicit roles. Used by setup endpoints to list Owner and Admin emails.

func (*Client) GetGroupRoleAssignment added in v0.15.0

func (c *Client) GetGroupRoleAssignment(ctx context.Context, groupName string) (*types.GroupRoleAssignment, error)

GetGroupRoleAssignment returns a specific group role assignment by group name.

func (*Client) GetGroupRoleAssignmentsForGroups added in v0.15.0

func (c *Client) GetGroupRoleAssignmentsForGroups(ctx context.Context, groupNames []string) ([]types.GroupRoleAssignment, error)

GetGroupRoleAssignmentsForGroups retrieves all role assignments for the given group names. This is used during role resolution to find all roles assigned to a user's groups.

func (*Client) GetImage added in v0.7.0

func (c *Client) GetImage(ctx context.Context, id string) (*types.Image, error)

GetImage retrieves an image by its ID

func (*Client) GetLLMAuditLog added in v0.24.0

func (c *Client) GetLLMAuditLog(ctx context.Context, id string, withSensitiveFields bool) (*types.LLMAuditLog, error)

func (*Client) GetLLMAuditLogAPIKeyFilterOptions added in v0.26.0

func (c *Client) GetLLMAuditLogAPIKeyFilterOptions(ctx context.Context, opts LLMAuditLogOptions) ([]apitypes.AuditLogAPIKeyFilterOption, error)

GetLLMAuditLogAPIKeyFilterOptions returns the API keys present in the currently filtered LLM audit-log result set.

func (*Client) GetLLMAuditLogFilterOptions added in v0.24.0

func (c *Client) GetLLMAuditLogFilterOptions(ctx context.Context, option string, opts LLMAuditLogOptions, exclude ...any) ([]string, error)

func (*Client) GetLLMAuditLogs added in v0.24.0

func (c *Client) GetLLMAuditLogs(ctx context.Context, opts LLMAuditLogOptions) ([]types.LLMAuditLog, int64, error)

func (*Client) GetMCPAuditLog added in v0.15.1

func (c *Client) GetMCPAuditLog(ctx context.Context, id uint, withRequestAndResponse bool) (*types.MCPAuditLog, error)

GetMCPAuditLog retrieves a single MCP audit log by ID

func (*Client) GetMCPAuditLogAPIKeyFilterOptions added in v0.26.0

func (c *Client) GetMCPAuditLogAPIKeyFilterOptions(ctx context.Context, opts MCPAuditLogOptions) ([]apitypes.AuditLogAPIKeyFilterOption, error)

GetMCPAuditLogAPIKeyFilterOptions returns the API keys present in the currently filtered and authorized MCP and local-agent audit-log result set.

func (*Client) GetMCPAuditLogs added in v0.8.0

func (c *Client) GetMCPAuditLogs(ctx context.Context, opts MCPAuditLogOptions) ([]types.MCPAuditLog, int64, error)

GetMCPAuditLogs retrieves a single, globally ordered page of audit rows from the selected sources. An empty SourceTypes selection preserves the MCP-only default. Mixed-source queries use each source's effective event time before applying one count, order, limit, and offset window. Sensitive payload fields are blanked unless WithRequestAndResponse is true.

func (*Client) GetMCPOAuthPendingState added in v0.17.0

func (c *Client) GetMCPOAuthPendingState(ctx context.Context, state string) (*types.MCPOAuthPendingState, error)

func (*Client) GetMCPOAuthToken added in v0.8.0

func (c *Client) GetMCPOAuthToken(ctx context.Context, userID, mcpID, url string) (*types.MCPOAuthToken, error)

func (*Client) GetMCPServerDetail added in v0.22.0

func (c *Client) GetMCPServerDetail(ctx context.Context, configHash string) (*types.MCPServerDetail, error)

GetMCPServerDetail returns the aggregated row keyed by config_hash plus the union of EnvKeys / HeaderKeys observed across the canonical rows. The aggregation is unbounded (all-time, all latest scans per device). Args is pulled from a canonical row (constant within a hash group, but JSONB has no MAX() in Postgres so it can't be selected with the GROUP BY).

func (*Client) GetMCPUsageStats added in v0.8.0

func (c *Client) GetMCPUsageStats(ctx context.Context, opts MCPUsageStatsOptions) (types.MCPUsageStatsList, error)

GetMCPUsageStats retrieves usage statistics for MCP servers

func (*Client) GetMDMAssetBundle added in v0.24.0

func (c *Client) GetMDMAssetBundle(ctx context.Context, digest string) (*types.MDMAssetBundle, error)

GetMDMAssetBundle returns and verifies a source archive by digest.

func (*Client) GetMDMConfiguration added in v0.24.0

func (c *Client) GetMDMConfiguration(ctx context.Context, id uint) (*types.MDMConfiguration, error)

GetMDMConfiguration retrieves a single configuration by ID.

func (*Client) GetMDMConfigurationEnforcement added in v0.25.0

func (c *Client) GetMDMConfigurationEnforcement(ctx context.Context, id uint) (types.MDMConfigurationEnforcement, error)

GetMDMConfigurationEnforcement retrieves just the enforcement policy of a configuration by ID.

func (*Client) GetMessagePolicyViolation added in v0.19.0

func (c *Client) GetMessagePolicyViolation(ctx context.Context, id uint) (*types.MessagePolicyViolation, error)

GetMessagePolicyViolation retrieves a single policy violation by ID and decrypts it.

func (*Client) GetMessagePolicyViolationFilterOptions added in v0.19.0

func (c *Client) GetMessagePolicyViolationFilterOptions(ctx context.Context, option string, opts MessagePolicyViolationOptions) ([]string, error)

GetMessagePolicyViolationFilterOptions returns distinct values for a given filter field.

func (*Client) GetMessagePolicyViolationStats added in v0.19.0

func (c *Client) GetMessagePolicyViolationStats(ctx context.Context, opts MessagePolicyViolationOptions) (*MessagePolicyViolationStats, error)

GetMessagePolicyViolationStats returns aggregated statistics for policy violations.

func (*Client) GetMessagePolicyViolations added in v0.19.0

func (c *Client) GetMessagePolicyViolations(ctx context.Context, opts MessagePolicyViolationOptions) ([]types.MessagePolicyViolation, int64, error)

GetMessagePolicyViolations retrieves policy violations with optional filters.

func (*Client) GetOrCreateProperty added in v0.23.0

func (c *Client) GetOrCreateProperty(ctx context.Context, key, value string) (types.Property, error)

func (*Client) GetProperty added in v0.13.0

func (c *Client) GetProperty(ctx context.Context, key string) (types.Property, error)

func (*Client) GetSCIMGroup added in v0.27.0

func (c *Client) GetSCIMGroup(ctx context.Context, connectionID, id string, includeMembers bool) (*SCIMGroup, error)

GetSCIMGroup returns the connection's bound group with the given SCIM ID.

func (*Client) GetSCIMUser added in v0.27.0

func (c *Client) GetSCIMUser(ctx context.Context, connectionID, id string) (*SCIMUser, error)

GetSCIMUser returns the connection's bound user with the given SCIM ID.

func (*Client) GetSetupTokenRequest added in v0.26.0

func (c *Client) GetSetupTokenRequest(ctx context.Context, id string) (*types.TokenRequest, error)

GetSetupTokenRequest returns a setup token request by ID.

func (*Client) GetSkillDetail added in v0.22.0

func (c *Client) GetSkillDetail(ctx context.Context, name string) (*types.SkillDetail, error)

GetSkillDetail returns the full per-skill payload for the dashboard drill-down: aggregated counts plus representative Description / HasScripts / GitRemoteURL / Files from one canonical row in the latest-scan-per-device subset. The aggregation is unbounded (all-time, all latest scans per device), matching the per-hash MCP detail's semantics.

func (*Client) GetTempUserCache added in v0.13.0

func (c *Client) GetTempUserCache(ctx context.Context) *types.TempSetupUser

GetTempUserCache retrieves the cached temporary user, if one exists. Returns nil if no user is cached.

func (*Client) GetUserGroupMemberships added in v0.15.0

func (c *Client) GetUserGroupMemberships(ctx context.Context, userIDs []uint) (map[uint][]string, error)

GetUserGroupMemberships fetches group memberships for multiple users in a single query. Returns a map of userID to slice of groupIDs.

func (*Client) GetUsersInGroup added in v0.15.0

func (c *Client) GetUsersInGroup(ctx context.Context, groupName string) ([]types.User, error)

GetUsersInGroup returns all users who are members of the given group. This is used to find users affected by GroupRoleAssignment changes.

func (*Client) HasCredential added in v0.27.0

func (c *Client) HasCredential(ctx context.Context, contexts []string, name string) (bool, error)

HasCredential reports whether a credential with name exists in any of contexts. It does not decrypt the credential, so it answers even when the credential could not be decrypted.

func (*Client) HasExplicitRole added in v0.12.0

func (c *Client) HasExplicitRole(email string) types2.Role

func (*Client) HasSignedInOwner added in v0.27.0

func (c *Client) HasSignedInOwner(ctx context.Context, authProviderName string) (bool, error)

HasSignedInOwner reports whether a user other than the bootstrap user counts as an Owner of the named auth provider: their stored role includes Owner, they are not deleted, and they have signed in through the provider. An identity alone is not enough, because an identity can exist before its user has signed in. A disabled Owner still counts: the identity provider that disabled them can reactivate them, while the bootstrap token was printed to the server logs.

func (*Client) InsertDeviceScan added in v0.22.0

func (c *Client) InsertDeviceScan(ctx context.Context, scan *types.DeviceScan) error

InsertDeviceScan persists a device scan envelope and all its children in a single GORM cascading insert. Each call creates a fresh row — duplicate submissions are not deduped at this layer.

func (*Client) InsertLLMAuditLog added in v0.24.0

func (c *Client) InsertLLMAuditLog(ctx context.Context, auditLog *types.LLMAuditLog) error

func (*Client) InsertLocalAgentAuditLogs added in v0.24.0

func (c *Client) InsertLocalAgentAuditLogs(ctx context.Context, logs []types.MCPAuditLog) error

InsertLocalAgentAuditLogs persists completed local-agent tool-call audit logs. Duplicate idempotency keys are treated as successful no-ops for transport retries.

func (*Client) InsertTokenUsage added in v0.8.0

func (c *Client) InsertTokenUsage(ctx context.Context, activity *types.RunTokenActivity) error

func (*Client) InvalidateMDMConfigurationArtifacts added in v0.24.0

func (c *Client) InvalidateMDMConfigurationArtifacts(ctx context.Context, latestDigest string) error

InvalidateMDMConfigurationArtifacts clears rendered downloads that were produced from any bundle other than latestDigest. Values and AssetDigest are retained so an administrator can review them against the latest fields.

func (*Client) IssueFirstSCIMConnectionToken added in v0.27.0

func (c *Client) IssueFirstSCIMConnectionToken(ctx context.Context, id string) (*types.SCIMConnection, string, error)

IssueFirstSCIMConnectionToken issues the bearer token of a connection that has none, and returns the connection with it. It returns ErrSCIMConnectionHasToken when the connection has a token already, so that of several callers only one is given a first token.

func (*Client) LLMAuditLogCount added in v0.26.0

func (c *Client) LLMAuditLogCount(ctx context.Context, start, end time.Time) (int64, error)

func (*Client) LLMAuditLogEnabled added in v0.24.0

func (c *Client) LLMAuditLogEnabled() bool

func (*Client) ListAPIKeys added in v0.16.0

func (c *Client) ListAPIKeys(ctx context.Context, userID uint) ([]types.APIKey, error)

ListAPIKeys returns active API keys for a user (without the secrets).

func (*Client) ListAPIKeysWithOptions added in v0.26.0

func (c *Client) ListAPIKeysWithOptions(ctx context.Context, userID uint, opts APIKeyListOptions) ([]types.APIKey, error)

ListAPIKeysWithOptions returns API keys for a user according to opts.

func (*Client) ListAllAPIKeys added in v0.16.0

func (c *Client) ListAllAPIKeys(ctx context.Context, opts APIKeyListOptions) ([]types.APIKey, error)

ListAllAPIKeys returns system API keys according to opts.

func (*Client) ListAuthGroups added in v0.9.0

func (c *Client) ListAuthGroups(ctx context.Context, authProviderURL, authProviderNamespace, authProviderName string, opts ListAuthGroupsOptions) (ListAuthGroupsResult, error)

ListAuthGroups returns one page of the auth provider's groups.

The auth provider is the authoritative source. When it cannot be listed, the response falls back to the groups table, which holds the groups observed during a user sign-in plus any resolved by ID for a policy, and is therefore partial.

For a provider that SCIM manages, the groups table holds its groups, bound and unbound alike, and the provider is never asked.

func (*Client) ListAuthTokens added in v0.26.0

func (c *Client) ListAuthTokens(ctx context.Context, userID uint) ([]types.AuthToken, error)

ListAuthTokens returns the auth tokens owned by a user.

func (*Client) ListCredentials added in v0.23.0

func (c *Client) ListCredentials(ctx context.Context, opts ListCredentialsOptions) ([]types.Credential, error)

ListCredentials returns the credentials in the given context. If AllContexts is true, CredentialContexts is ignored and credentials from all contexts are returned. The secrets in the returned credentials are blanked out for security; use RevealCredential to get the secrets for a specific credential.

func (*Client) ListDeviceClientFleetSummaries added in v0.22.0

func (c *Client) ListDeviceClientFleetSummaries(ctx context.Context, opts DeviceClientFleetListOptions) ([]DeviceClientFleetSummary, int64, error)

ListDeviceClientFleetSummaries returns one row per distinct client name observed in device_scan_clients on each device's all-time latest scan, paginated after applying the selected sort order. Each row lists distinct submitters, skills with metadata, and MCP servers (by config_hash) attributed to that client on those scans. Optional Name filters distinct names by case-insensitive substring match.

func (*Client) ListDeviceEnrollmentKeys added in v0.24.0

func (c *Client) ListDeviceEnrollmentKeys(ctx context.Context, configurationID uint) ([]types.DeviceEnrollmentKey, error)

ListDeviceEnrollmentKeys returns the (secret-free) keys for a configuration, newest first.

func (*Client) ListDeviceScans added in v0.22.0

func (c *Client) ListDeviceScans(ctx context.Context, opts DeviceScanListOptions) ([]types.DeviceScan, int64, error)

ListDeviceScans returns scan envelopes ordered newest first. MCP servers, skills, and plugins are preloaded; files are not — DeviceScanFile.Content can be large and isn't needed for the list.

func (*Client) ListDevices added in v0.24.0

func (c *Client) ListDevices(ctx context.Context, configurationID uint) ([]types.Device, error)

ListDevices returns the devices enrolled into a configuration, newest first.

func (*Client) ListEgressAuditLogs added in v0.27.0

func (c *Client) ListEgressAuditLogs(ctx context.Context, opts EgressAuditLogOptions) ([]types.EgressAuditLog, int64, error)

func (*Client) ListGroupIDsForUser added in v0.9.0

func (c *Client) ListGroupIDsForUser(ctx context.Context, userID uint) ([]string, error)

ListGroupIDsForUser lists the group IDs that the given user is a member of. This can include groups from multiple auth providers.

func (*Client) ListGroupRoleAssignments added in v0.15.0

func (c *Client) ListGroupRoleAssignments(ctx context.Context) ([]types.GroupRoleAssignment, error)

ListGroupRoleAssignments returns all group role assignments from the database.

func (*Client) ListMCPServerOccurrences added in v0.22.0

func (c *Client) ListMCPServerOccurrences(ctx context.Context, configHash string, limit, offset int) ([]types.MCPServerOccurrence, int64, error)

ListMCPServerOccurrences returns one row per (device, observation) for the given config_hash, drawn from the all-time latest scan of every device. Sorted scanned_at DESC, paginated.

func (*Client) ListMDMConfigurations added in v0.24.0

func (c *Client) ListMDMConfigurations(ctx context.Context) ([]types.MDMConfiguration, error)

ListMDMConfigurations returns the default first, then newest first.

func (*Client) ListSCIMGroups added in v0.27.0

func (c *Client) ListSCIMGroups(ctx context.Context, connectionID string, filter SCIMGroupFilter, page SCIMPage, includeMembers bool) ([]SCIMGroup, int64, error)

ListSCIMGroups returns the connection's bound groups that match filter, oldest first, and the total number of matches. Groups that SCIM has not bound are never returned.

func (*Client) ListSCIMUsers added in v0.27.0

func (c *Client) ListSCIMUsers(ctx context.Context, connectionID string, filter SCIMUserFilter, page SCIMPage) ([]SCIMUser, int64, error)

ListSCIMUsers returns the connection's bound users that match filter, oldest first, and the total number of matches. Users that SCIM has not provisioned are never returned.

func (*Client) ListServiceAccountAPIKeys added in v0.21.0

func (c *Client) ListServiceAccountAPIKeys(ctx context.Context, serviceAccountName string) ([]types.ServiceAccountAPIKey, error)

func (*Client) ListSkillOccurrences added in v0.22.0

func (c *Client) ListSkillOccurrences(ctx context.Context, name string, limit, offset int) ([]types.SkillOccurrence, int64, error)

ListSkillOccurrences returns one row per (device, observation) for the given skill name, drawn from the all-time latest scan of every device. Sorted scanned_at DESC, paginated.

func (*Client) ListSkillStats added in v0.22.0

func (c *Client) ListSkillStats(ctx context.Context, opts SkillStatListOptions) ([]types.SkillStat, int64, error)

ListSkillStats returns one row per distinct skill name observed in the latest scan of any device within the requested window. Paginated, sortable, optional name LIKE filter.

func (*Client) LocalAuthRequiresActivation added in v0.26.0

func (c *Client) LocalAuthRequiresActivation(ctx context.Context) (bool, error)

LocalAuthRequiresActivation reports whether an initial owner still has to activate their setup link. Expiry is intentionally ignored so an expired link still reaches the activation page.

func (*Client) LocalAuthSession added in v0.24.0

func (c *Client) LocalAuthSession(ctx context.Context, id string) (*types.LocalAuthSession, *types.LocalAuthUser, error)

LocalAuthSession returns the unexpired session with the given ID, along with its user. Expired sessions are treated as missing and deleted.

func (*Client) LocalAuthUserByEmail added in v0.24.0

func (c *Client) LocalAuthUserByEmail(ctx context.Context, email string) (*types.LocalAuthUser, error)

func (*Client) LocalAuthUserByID added in v0.24.0

func (c *Client) LocalAuthUserByID(ctx context.Context, id uint) (*types.LocalAuthUser, error)

func (*Client) LocalAuthUsers added in v0.24.0

func (c *Client) LocalAuthUsers(ctx context.Context) ([]types.LocalAuthUser, error)

func (*Client) LogEgressAuditEntry added in v0.27.0

func (c *Client) LogEgressAuditEntry(entry types.EgressAuditLog)

LogEgressAuditEntry queues a completed capture or final transport status.

func (*Client) LogEnforcementDecision added in v0.25.0

func (c *Client) LogEnforcementDecision(entry types.EnforcementDecisionLog)

LogEnforcementDecision buffers the decision row for asynchronous persistence. The decision endpoint returns to the device before the row is durably flushed, keeping the database off the synchronous decision path (the block/allow verdict never waits on a write).

func (*Client) LogLLMAuditEntry added in v0.24.0

func (c *Client) LogLLMAuditEntry(auditLog types.LLMAuditLog, responseStream []byte)

func (*Client) LogMCPAuditEntry added in v0.10.0

func (c *Client) LogMCPAuditEntry(entry types.MCPAuditLog)

func (*Client) LogMessagePolicyViolation added in v0.19.0

func (c *Client) LogMessagePolicyViolation(ctx context.Context, v *types.MessagePolicyViolation) error

LogMessagePolicyViolation encrypts sensitive fields and inserts a violation record.

func (*Client) MCPToolCallCount added in v0.26.0

func (c *Client) MCPToolCallCount(ctx context.Context, start, end time.Time) (int64, error)

func (*Client) MarkClaudeWorkOrderSubmitted added in v0.27.0

func (c *Client) MarkClaudeWorkOrderSubmitted(ctx context.Context, name string) error

func (*Client) MarkUnreferencedSCIMGroups added in v0.27.0

func (c *Client) MarkUnreferencedSCIMGroups(ctx context.Context, conn *types.SCIMConnection, referenced map[string]struct{}) (*SCIMDeletionRun, error)

MarkUnreferencedSCIMGroups starts a deletion of unreferenced groups: it marks the unbound groups of the connection's auth provider whose IDs are not in referenced as pending deletion, and returns once every write of group references that could have missed the marks has finished.

The references that decide which groups are deleted live in the controller store, which cannot share a transaction with the gateway database. Writers of references record their write before they check for marks. From the moment the marks commit, a write recorded afterwards sees them and is refused, and a pushed group no longer binds to a marked group. The writes recorded by then are waited for, so the references read after this returns include theirs, and are the last that can reach the marked groups.

A group that another deletion marked is taken over. Only the deletion that marked a group deletes it, once it has read the references again.

func (*Client) MatchClaudeOrganizationAccount added in v0.27.0

func (c *Client) MatchClaudeOrganizationAccount(ctx context.Context, organization, account, email string) (*types.ClaudeOrganizationAccount, error)

MatchClaudeOrganizationAccount runs under the provisioning lock shared with admin edits. Only the authenticated orchestrator supplies the account and email.

func (*Client) MigrateGPTScriptCredentials added in v0.23.0

func (c *Client) MigrateGPTScriptCredentials(ctx context.Context, oldDB *gorm.DB) error

MigrateGPTScriptCredentials migrates existing GPTScript credentials into the gateway credentials table. The old GPTScript id, server_url, and username fields are intentionally not copied; server_url only supplies the new name.

func (*Client) MigrateKinmIfNotRun added in v0.26.1

func (c *Client) MigrateKinmIfNotRun(ctx context.Context, name string, f func() error) error

MigrateKinmIfNotRun runs f unless the named migration has already succeeded. It does not hold a transaction open, so f can access storage through other clients.

func (*Client) MigrateToolReferenceCredentialContexts added in v0.23.0

func (c *Client) MigrateToolReferenceCredentialContexts(ctx context.Context) error

MigrateToolReferenceCredentialContexts moves credentials that were scoped by a ToolReference UID into a context matching their credential name. It must run after MigrateGPTScriptCredentials because that migration creates the gateway credential rows from the old GPTScript credential store.

func (*Client) ModelProxyEnabled added in v0.26.0

func (c *Client) ModelProxyEnabled(ctx context.Context) (bool, error)

ModelProxyEnabled reads shared state on every call. Only an absent property uses the backwards-compatible default.

func (*Client) PatchSCIMGroup added in v0.27.0

func (c *Client) PatchSCIMGroup(ctx context.Context, conn *types.SCIMConnection, id string, patch SCIMGroupPatch) error

PatchSCIMGroup applies a patch to a bound group. Unlike UpdateSCIMGroup, it never loads the group's members: adding and removing members reads and writes only the memberships of the users the patch names, and replacing them reads only the user IDs of the group's memberships. A patch that changes nothing emits nothing.

func (*Client) PollTokenRequest added in v0.26.0

func (c *Client) PollTokenRequest(ctx context.Context, id string) (*types.TokenRequest, error)

PollTokenRequest returns a token request and marks an available token as retrieved.

func (*Client) PruneUnusedMDMAssetBundles added in v0.24.0

func (c *Client) PruneUnusedMDMAssetBundles(ctx context.Context, retainDigests ...string) error

PruneUnusedMDMAssetBundles removes source archives absent from retainDigests.

func (*Client) RecordSCIMRequest added in v0.27.0

func (c *Client) RecordSCIMRequest(ctx context.Context, connectionID string, outcome SCIMRequestOutcome) error

RecordSCIMRequest records an authenticated SCIM request of the connection: its time, and for a failed request, the failure. It records nothing for a connection that no longer exists.

func (*Client) RefreshLocalAuthUserSetupToken added in v0.26.0

func (c *Client) RefreshLocalAuthUserSetupToken(ctx context.Context, id uint, setupTokenHash string, setupTokenExpiresAt time.Time) error

RefreshLocalAuthUserSetupToken rotates a still-pending setup token and invalidates the sessions created with the old one. Completed accounts cannot be rearmed.

func (*Client) RemainingTokenUsageForUser added in v0.8.0

func (c *Client) RemainingTokenUsageForUser(ctx context.Context, userID string, period time.Duration, inputTokenLimit, outputTokenLimit int) (*types.RemainingTokenUsage, error)

func (*Client) RemoveIdentity added in v0.5.0

func (c *Client) RemoveIdentity(ctx context.Context, id *types.Identity) error

RemoveIdentity deletes an identity from the database. The identity is deleted using UserID if set, otherwise ProviderUsername. The method is idempotent and ignores not-found errors, returning only unexpected errors.

The identities of a user that SCIM has provisioned are never removed: the identity provider must deprovision the user, and deleting the user retires the binding first.

func (*Client) RemoveIdentityAndUser added in v0.9.0

func (c *Client) RemoveIdentityAndUser(ctx context.Context, id *types.Identity) (uint, error)

RemoveIdentityAndUser deletes an identity and the associated user from the database. The identity and user are deleted using UserID if set, otherwise ProviderUsername. The method is idempotent and ignores not-found errors, returning only unexpected errors.

func (*Client) ReplaceMCPOAuthToken added in v0.8.0

func (c *Client) ReplaceMCPOAuthToken(ctx context.Context, userID, mcpID, url, oauthAuthRequestID string, oauthConf *oauth2.Config, token *oauth2.Token) error

func (*Client) ResolveAuthGroups added in v0.25.2

func (c *Client) ResolveAuthGroups(ctx context.Context, authProviderURL, authProviderNamespace, authProviderName string, ids []string) ([]types.Group, error)

ResolveAuthGroups looks up specific groups by ID, which is what the UI needs to render a name for a group that already has a role or policy attached.

Note the shape: cache first, provider only for the remainder. Resolution runs on page loads, so making it an unconditional provider call would put an identity provider round trip, and its rate limit, in front of every admin screen.

For a provider that SCIM manages, the groups table holds its groups, and the provider is never asked.

func (*Client) ResolveUserEffectiveRole added in v0.15.0

func (c *Client) ResolveUserEffectiveRole(ctx context.Context, user *types.User, authGroupIDs []string) (types2.Role, error)

ResolveUserEffectiveRole computes the effective role for a user by combining: 1. Individual role from users table 2. Group-based roles from GroupRoleAssignments Returns the highest base role plus orthogonal add-on roles (if present).

func (*Client) ResolveUserEffectiveRolesBulk added in v0.15.0

func (c *Client) ResolveUserEffectiveRolesBulk(ctx context.Context, users []types.User, userGroupMemberships map[uint][]string) (map[uint]types2.Role, error)

ResolveUserEffectiveRolesBulk computes effective roles for multiple users efficiently. It performs a single database query to fetch all group role assignments for all users' groups. Returns a map of userID to their effective role.

func (*Client) RetireOtherServiceAccountAPIKeys added in v0.21.0

func (c *Client) RetireOtherServiceAccountAPIKeys(ctx context.Context, serviceAccountName string, activeID uint, retireAfter time.Time) error

func (*Client) RevealAuthProviderCredential added in v0.27.0

func (c *Client) RevealAuthProviderCredential(ctx context.Context, contexts []string, namespace, name string) (types.Credential, string, error)

RevealAuthProviderCredential is RevealCredential for the credential of the auth provider namespace/name, and also returns the adapter type of the provider's SCIM connection, or "" when it has none. It reads both in one query, as it runs for every request that checks whether the provider is configured.

func (*Client) RevealCredential added in v0.23.0

func (c *Client) RevealCredential(ctx context.Context, contexts []string, name string) (types.Credential, error)

RevealCredential returns the first credential matching name in the ordered list of contexts.

func (*Client) RevokeAPIKey added in v0.26.0

func (c *Client) RevokeAPIKey(ctx context.Context, userID uint, keyID uint) error

RevokeAPIKey immediately disables an API key while retaining its metadata. Repeated revocation is idempotent and preserves the original revocation time.

func (*Client) RevokeAPIKeyByID added in v0.26.0

func (c *Client) RevokeAPIKeyByID(ctx context.Context, keyID uint) error

RevokeAPIKeyByID immediately disables an API key without user filtering while retaining its metadata for audit history.

func (*Client) RevokeCurrentSCIMConnectionToken added in v0.27.0

func (c *Client) RevokeCurrentSCIMConnectionToken(ctx context.Context, id string) (*types.SCIMConnection, string, error)

RevokeCurrentSCIMConnectionToken replaces a leaked bearer token: in one step, it issues a new token, which it returns with the updated connection, and stops accepting both the current token and the previous one.

func (*Client) RevokePreviousSCIMConnectionToken added in v0.27.0

func (c *Client) RevokePreviousSCIMConnectionToken(ctx context.Context, id string) error

RevokePreviousSCIMConnectionToken stops accepting the token that the last rotation replaced.

func (*Client) RotateSCIMConnectionToken added in v0.27.0

func (c *Client) RotateSCIMConnectionToken(ctx context.Context, id string) (*types.SCIMConnection, string, error)

RotateSCIMConnectionToken issues a new bearer token for the connection and returns the updated connection with it. This also issues the first token of a connection that has none. The token it replaces is still accepted for a day, or until it expires, RevokePreviousSCIMConnectionToken is called, or the token is rotated again, so the identity provider can be switched over without failed requests.

func (*Client) RunEgressAuditCleanup added in v0.27.0

func (c *Client) RunEgressAuditCleanup(ctx context.Context, days int)

func (*Client) SCIMConnection added in v0.27.0

func (c *Client) SCIMConnection(ctx context.Context, id string) (*types.SCIMConnection, error)

SCIMConnection returns the SCIM connection with the given ID, or ErrSCIMConnectionNotFound.

func (*Client) SCIMConnectionForAuthProvider added in v0.27.0

func (c *Client) SCIMConnectionForAuthProvider(ctx context.Context, namespace, name string) (*types.SCIMConnection, error)

SCIMConnectionForAuthProvider returns the SCIM connection of the auth provider, or nil when the provider has none and still synchronizes its directory at sign-in. Callers must treat an error as unknown, and never fall back to the directory.

func (*Client) SCIMConnections added in v0.27.0

func (c *Client) SCIMConnections(ctx context.Context) ([]types.SCIMConnection, error)

SCIMConnections returns every SCIM connection: zero or one.

func (*Client) SCIMGroupDeletionInProgress added in v0.27.0

func (c *Client) SCIMGroupDeletionInProgress(ctx context.Context, connectionID string) (bool, error)

SCIMGroupDeletionInProgress reports whether a deletion of the connection's unreferenced groups holds marks for deletion that have not expired.

func (*Client) SCIMManagedUsers added in v0.27.0

func (c *Client) SCIMManagedUsers(ctx context.Context, userIDs []uint) (map[uint]struct{}, error)

SCIMManagedUsers returns the users in userIDs with an unretired SCIM binding.

func (*Client) SCIMProviderGroups added in v0.27.0

func (c *Client) SCIMProviderGroups(ctx context.Context, namespace, name string) ([]SCIMProviderGroup, error)

SCIMProviderGroups returns the groups of the auth provider, bound and unbound, ordered by name.

func (*Client) SCIMProvisionedUsers added in v0.27.0

func (c *Client) SCIMProvisionedUsers(ctx context.Context, conn *types.SCIMConnection, page SCIMPage) ([]SCIMSetupUser, int64, error)

SCIMProvisionedUsers returns a page of the users that the connection has provisioned, oldest binding first, and how many there are.

func (*Client) SCIMRequestFailurePage added in v0.27.0

func (c *Client) SCIMRequestFailurePage(ctx context.Context, connectionID string, page SCIMPage) ([]types.SCIMRequestFailure, int64, error)

SCIMRequestFailurePage returns a page of the connection's recent failed requests, newest first, and how many are kept.

func (*Client) SCIMUnprovisionedUsers added in v0.27.0

func (c *Client) SCIMUnprovisionedUsers(ctx context.Context, conn *types.SCIMConnection, page SCIMPage) ([]SCIMSetupUser, int64, error)

SCIMUnprovisionedUsers returns a page of the live users of the connection's auth provider that the connection has not provisioned, oldest first, and how many there are. Enforcing SCIM disables them.

func (*Client) SCIMUserBindingForUser added in v0.27.0

func (c *Client) SCIMUserBindingForUser(ctx context.Context, userID uint) (*types.SCIMUserBinding, error)

SCIMUserBindingForUser returns the unretired SCIM binding of a user, or nil when SCIM has not provisioned the user. The returned binding is still encrypted.

func (*Client) SaveClaudeEnvironment added in v0.27.0

func (c *Client) SaveClaudeEnvironment(ctx context.Context, environment *types.ClaudeEnvironment, secrets map[string]string) error

SaveClaudeEnvironment atomically stores metadata and write-only credentials. Environment keys follow the same encryption configuration as other credentials.

func (*Client) SaveClaudeOrganizationAccounts added in v0.27.0

func (c *Client) SaveClaudeOrganizationAccounts(ctx context.Context, organization string, accounts []types.ClaudeOrganizationAccount) error

SaveClaudeOrganizationAccounts runs under the provisioning lock. Omitted accounts are preserved; an explicit empty UserID removes a mapping. Validate the merged result before writing so reassignments and swaps are atomic.

func (*Client) SaveClaudeWorkOrder added in v0.27.0

func (c *Client) SaveClaudeWorkOrder(ctx context.Context, credential types.Credential) error

func (*Client) SaveEgressAuditLog added in v0.27.0

func (c *Client) SaveEgressAuditLog(ctx context.Context, entry types.EgressAuditLog) error

SaveEgressAuditLog persists a capture without overwriting final transport status.

func (*Client) SetLocalAuthUserPassword added in v0.24.0

func (c *Client) SetLocalAuthUserPassword(ctx context.Context, id uint, passwordHash string, requirePasswordChange bool) error

SetLocalAuthUserPassword updates a user's password hash and invalidates all of their sessions, so that a password reset actually kicks the old sessions out.

func (*Client) SetModelProxyEnabled added in v0.26.0

func (c *Client) SetModelProxyEnabled(ctx context.Context, enabled bool) error

SetModelProxyEnabled uses an atomic upsert so concurrent first writes cannot race to create the singleton. Preserve the existing property encryption path.

func (*Client) SetProperty added in v0.13.0

func (c *Client) SetProperty(ctx context.Context, key, value string) (types.Property, error)

SetProperty creates or overwrites the property with a single upsert, so writers racing to create it don't conflict. The returned property's CreatedAt is the time of this write, even when the property already existed.

func (*Client) SetTempUserCache added in v0.13.0

func (c *Client) SetTempUserCache(ctx context.Context, user *types.User, authProviderName, authProviderNamespace string) error

SetTempUserCache stores a temporary user in the database for the bootstrap setup flow. Returns an error if a user is already cached.

func (*Client) StoreMDMAssetBundle added in v0.24.0

func (c *Client) StoreMDMAssetBundle(ctx context.Context, content []byte) (string, error)

StoreMDMAssetBundle stores an immutable source archive under its SHA-256 digest. Re-storing the same archive repairs the stored content.

func (*Client) TokenUsageByUser added in v0.8.0

func (c *Client) TokenUsageByUser(ctx context.Context, start, end time.Time) ([]types.RunTokenActivity, error)

func (*Client) TokenUsageForUser added in v0.8.0

func (c *Client) TokenUsageForUser(ctx context.Context, userID string, start, end time.Time) ([]types.RunTokenActivity, error)

func (*Client) TokenUsageSeriesInRange added in v0.17.0

func (c *Client) TokenUsageSeriesInRange(ctx context.Context, start, end time.Time) ([]types.RunTokenActivity, error)

TokenUsageSeriesInRange returns all individual token usage records in the time range for all users. Results are ordered by created_at descending. The range is [start, end] inclusive so that the requested end time is the last moment included.

func (*Client) TotalTokenUsageForUser added in v0.8.0

func (c *Client) TotalTokenUsageForUser(ctx context.Context, userID string, start, end time.Time) (types.RunTokenActivity, error)

func (*Client) UpdateAPIKeyLastUsed added in v0.16.0

func (c *Client) UpdateAPIKeyLastUsed(ctx context.Context, key *types.APIKey) error

UpdateAPIKeyLastUsed updates the last_used_at timestamp for an API key if more than a minute has elapsed since the previous timestamp.

func (*Client) UpdateGroupRoleAssignment added in v0.15.0

func (c *Client) UpdateGroupRoleAssignment(ctx context.Context, groupName string, role types2.Role, description string) (*types.GroupRoleAssignment, error)

UpdateGroupRoleAssignment updates an existing group role assignment.

func (*Client) UpdateMDMConfiguration added in v0.24.0

func (c *Client) UpdateMDMConfiguration(ctx context.Context, configuration *types.MDMConfiguration) error

UpdateMDMConfiguration updates a configuration and atomically replaces its rendered artifacts in the same transaction.

func (*Client) UpdateMDMConfigurationEnforcement added in v0.25.0

func (c *Client) UpdateMDMConfigurationEnforcement(ctx context.Context, id uint, enabled bool, allowlist types2.EnforcementAllowlist, artifacts []types.MDMConfigurationArtifact) error

UpdateMDMConfigurationEnforcement updates only the enforcement policy columns of a configuration and atomically replaces its rendered artifacts in the same transaction, mirroring UpdateMDMConfiguration. The device bundle bakes in the enforcement toggle, so a toggle change must swap in freshly rendered artifacts; a blank configuration (no pinned asset) passes no artifacts and only its columns change.

func (*Client) UpdateProfileIfNeeded added in v0.8.0

func (c *Client) UpdateProfileIfNeeded(ctx context.Context, user *types.User, authProviderName, authProviderNamespace, authProviderURL string) error

func (*Client) UpdateSCIMGroup added in v0.27.0

func (c *Client) UpdateSCIMGroup(ctx context.Context, conn *types.SCIMConnection, id string, mutate func(current SCIMGroup) (SCIMGroupInput, error)) error

UpdateSCIMGroup changes a bound group's display name and members. The replacement is computed by mutate from the group's current state, with its members, inside the transaction that writes it. A replacement identical to the current state changes nothing and emits nothing. A replacement that does not depend on the current state is a PatchSCIMGroup that replaces the members, which reads none of them.

func (*Client) UpdateSCIMUser added in v0.27.0

func (c *Client) UpdateSCIMUser(ctx context.Context, conn *types.SCIMConnection, id string, mutate func(current SCIMUser) (SCIMUserInput, error)) (*SCIMUser, error)

UpdateSCIMUser changes a bound user. The replacement is computed by mutate from the user's current state, inside the transaction that writes it, so that concurrent writes cannot interleave. A replacement identical to the current state changes nothing.

func (*Client) UpdateUser added in v0.5.0

func (c *Client) UpdateUser(ctx context.Context, actingUserCanChangeRole bool, updatedUser *types.User, userID string) (*types.User, error)

func (*Client) UpdateUserInternalStatus added in v0.8.0

func (c *Client) UpdateUserInternalStatus(ctx context.Context, userID string, internal bool) error

func (*Client) UpsertCredential added in v0.23.0

func (c *Client) UpsertCredential(ctx context.Context, credential types.Credential) error

UpsertCredential creates or replaces a credential identified by context+name.

func (*Client) User

func (c *Client) User(ctx context.Context, username string) (*types.User, error)

func (*Client) UserByID

func (c *Client) UserByID(ctx context.Context, id string) (*types.User, error)

func (*Client) UserByIDIncludeDeleted added in v0.9.0

func (c *Client) UserByIDIncludeDeleted(ctx context.Context, id string) (*types.User, error)

UserByIDIncludeDeleted returns a user by ID including soft-deleted users (for audit purposes)

func (*Client) UserByIDWithEffectiveRole added in v0.26.1

func (c *Client) UserByIDWithEffectiveRole(ctx context.Context, id uint) (*types.User, []string, error)

UserByIDWithEffectiveRole returns the user with the corresponding ID with their effiective role and auth provider groups.

func (*Client) UserCount added in v0.25.0

func (c *Client) UserCount(ctx context.Context) (int64, error)

func (*Client) UserFromProviderUserID added in v0.24.0

func (c *Client) UserFromProviderUserID(ctx context.Context, providerNamespace, providerName, providerUserID string) (*types.User, error)

UserFromProviderUserID returns a user by their provider user ID

func (*Client) UserFromToken added in v0.8.0

func (c *Client) UserFromToken(ctx context.Context, token string) (*types.User, string, string, string, []string, error)

func (*Client) UserInfoByID added in v0.16.0

func (c *Client) UserInfoByID(ctx context.Context, userID uint) (kuser.Info, error)

UserInfoByID returns a user.Info object for the given user ID, suitable for use with ACR helper methods. This fetches the user and their group memberships from the database.

func (*Client) UserStatus added in v0.27.0

func (c *Client) UserStatus(ctx context.Context, userID uint) (types2.UserStatus, error)

UserStatus reads a user's current lifecycle status. A user with no row is reported as deleted. It returns a *UserAccessLookupError if the status could not be read.

func (*Client) Users added in v0.5.0

func (c *Client) Users(ctx context.Context, query types.UserQuery) ([]types.User, error)

func (*Client) UsersIncludeDeleted added in v0.9.0

func (c *Client) UsersIncludeDeleted(ctx context.Context, query types.UserQuery) ([]types.User, error)

UsersIncludeDeleted returns all users including soft-deleted ones (for audit purposes)

func (*Client) VMCPToolCallCount added in v0.26.2

func (c *Client) VMCPToolCallCount(ctx context.Context, start, end time.Time) (int64, error)

func (*Client) ValidateAPIKey added in v0.16.0

func (c *Client) ValidateAPIKey(ctx context.Context, key string) (*types.APIKey, error)

ValidateAPIKey validates an API key and returns the associated APIKey record. The key format is: ok1-<user_id>-<key_id>-<secret> Lookup is done by key ID, then bcrypt is used to verify the secret. Cache hits avoid repeating bcrypt but still check persisted lifecycle state so revocation on one server replica takes effect on every replica immediately. On cache misses, last_used_at is updated only if more than a minute has elapsed.

func (*Client) ValidateDeviceEnrollmentCredential added in v0.24.0

func (c *Client) ValidateDeviceEnrollmentCredential(ctx context.Context, credential string) (*types.DeviceEnrollmentKey, error)

ValidateDeviceEnrollmentCredential parses an ode1-... credential, loads its key, and accepts it when the key exists (scoped to the configuration), is not expired, and the secret matches. Returns the key on success.

func (*Client) ValidateStorageServiceAccountToken added in v0.21.0

func (c *Client) ValidateStorageServiceAccountToken(ctx context.Context, token string) (*types.ServiceAccountAPIKey, error)

func (*Client) VerifyTokenRequestState added in v0.26.0

func (c *Client) VerifyTokenRequestState(ctx context.Context, state string) (*types.TokenRequest, error)

VerifyTokenRequestState consumes OAuth state and returns its setup token request.

func (*Client) WaitForSCIMReferenceWrites added in v0.27.0

func (c *Client) WaitForSCIMReferenceWrites(ctx context.Context) error

WaitForSCIMReferenceWrites waits until the writes of group references recorded now have finished or expired. A write recorded later checks its groups after the caller's changes to them, such as marks for deletion, committed.

func (*Client) WithClaudeProvisionLock added in v0.27.0

func (c *Client) WithClaudeProvisionLock(ctx context.Context, fn func() error) error

ponytail: global admission lock; use per-account/session locks if provisioning throughput warrants it. Serialize admission and order deduplication across Obot replicas. Provisioning only writes desired state; this lock is never held while waiting for a runner to boot.

func (*Client) WithNewSCIMGroupReferences added in v0.27.0

func (c *Client) WithNewSCIMGroupReferences(ctx context.Context, groupIDs []string, write func() error) error

WithNewSCIMGroupReferences runs write, which saves new references to groupIDs, once they are known to reach groups of a SCIM connection's auth provider, and returns what write returns. It returns a *SCIMGroupReferenceError without running write when a group ID has a connection's group ID prefix and no group of the connection's auth provider has it, or the group is being deleted because nothing referenced it. The identity provider pushes every group of such a provider, so a group that does not exist yet has no ID that a reference could use.

The write is recorded before the references are checked, and until it finishes. A deletion of unreferenced groups whose marks commit after the check waits for it, and reads the references it saved; one whose marks commit before the check refuses it. No database connection is held while write runs. write must save the references before it returns, within scimReferenceWriteLifetime.

Callers pass only the group IDs that a write adds, so an old reference to a missing group does not block unrelated edits.

type CreateSCIMConnectionOptions added in v0.27.0

type CreateSCIMConnectionOptions struct {
	AuthProviderNamespace string
	AuthProviderName      string
	GroupIDPrefix         string
	Issuer                string
	Origin                types.SCIMConnectionOrigin
	// IssueToken issues the connection's first bearer token. Without it, the connection has no token, and every
	// request to it is refused until one is issued.
	IssueToken bool
	// RequireNoGroupData refuses to create the connection with *SCIMResidualGroupDataError while the auth provider
	// has any group data in the gateway database: groups, or memberships or group role assignments of group IDs
	// with its group ID prefix. A connection created without directory credentials must start without groups,
	// because nothing but SCIM could ever correct them.
	RequireNoGroupData bool
}

CreateSCIMConnectionOptions describes the auth provider a new SCIM connection manages.

type CredentialNotFoundError added in v0.23.0

type CredentialNotFoundError struct {
	Contexts []string
	Name     string
}

func (CredentialNotFoundError) Error added in v0.23.0

func (e CredentialNotFoundError) Error() string

func (CredentialNotFoundError) Unwrap added in v0.23.0

func (e CredentialNotFoundError) Unwrap() error

type DeletedSCIMConnection added in v0.27.0

type DeletedSCIMConnection struct {
	ConnectionID string
}

DeletedSCIMConnection is what deleting the SCIM connection of an auth provider did.

type DeviceClientFleetListOptions added in v0.22.0

type DeviceClientFleetListOptions struct {
	// Name, when non-empty after trimming, restricts distinct client names to
	// those matching as a case-insensitive substring (LIKE/ILIKE %Name%).
	Name string
	// SortBy is name | mcp_server_count | skill_count | user_count.
	SortBy string
	// SortOrder is asc | desc.
	SortOrder string
	// Limit is the max number of client rows to return; 0 means no limit.
	Limit int
	// Offset skips that many client names in the selected sort order.
	Offset int
}

DeviceClientFleetListOptions configures ListDeviceClientFleetSummaries.

type DeviceClientFleetSkill added in v0.22.0

type DeviceClientFleetSkill struct {
	Name        string
	Description string
	HasScripts  bool
	Files       int
}

DeviceClientFleetSkill is gateway-layer skill metadata for client summaries.

type DeviceClientFleetSummary added in v0.22.0

type DeviceClientFleetSummary struct {
	Name       string
	Users      []string
	Skills     []DeviceClientFleetSkill
	MCPServers []types.MCPServerStat
}

DeviceClientFleetSummary is the gateway-layer aggregate for one client name; callers map it to apiclient types.

type DeviceEnrollment added in v0.24.0

type DeviceEnrollment struct {
	DeviceID           string
	MDMConfigurationID uint
	PublicKey          []byte
	Hostname           string
	OS                 string
	OSVersion          string
}

DeviceEnrollment is the input to enrolling (or re-enrolling) a device. PublicKey is DER SubjectPublicKeyInfo (PKIX) of the device identity key.

type DeviceLimit added in v0.25.0

type DeviceLimit struct {
	Maximum   int64
	Unlimited bool
}

DeviceLimit describes the maximum number of devices an installation may have. Maximum is ignored when Unlimited is true.

type DeviceLimitProvider added in v0.25.0

type DeviceLimitProvider interface {
	DeviceLimit(context.Context) (DeviceLimit, error)
}

DeviceLimitProvider resolves the current license-derived device limit.

type DeviceScanListOptions added in v0.22.0

type DeviceScanListOptions struct {
	SubmittedBy   []string
	DeviceID      []string
	Limit         int
	Offset        int
	GroupByDevice bool
}

DeviceScanListOptions filters the scan-envelope list endpoint. SubmittedBy and DeviceID are multi-value; either narrows the result.

type DeviceScanStatsOptions added in v0.22.0

type DeviceScanStatsOptions struct {
	StartTime time.Time
	EndTime   time.Time
}

DeviceScanStatsOptions bounds the dashboard rollup. Zero-valued times are treated as unbounded; callers normally pass a recent window (e.g. last 60 days).

type DeviceScanStatsResult added in v0.22.0

type DeviceScanStatsResult struct {
	StartTime      time.Time
	EndTime        time.Time
	DeviceCount    int64
	UserCount      int64
	Clients        []types.ClientStat
	MCPServers     []types.MCPServerStat
	Skills         []types.SkillStat
	ScanTimestamps []time.Time
}

DeviceScanStatsResult is the dashboard rollup payload.

type EgressAuditLogOptions added in v0.27.0

type EgressAuditLogOptions struct {
	UserID, ClaudeAccount, EnvironmentID, ClaudeSession, Host, Outcome string
	StartTime, EndTime                                                 time.Time
	Limit, Offset                                                      int
}

type EnforceSCIMOptions added in v0.27.0

type EnforceSCIMOptions struct {
	// RunID identifies the deletion that marked the unreferenced groups. Enforcing deletes only the groups it marked.
	RunID string
	// ReferencedGroupIDs are the IDs of the groups that anything references, read after the deletion's marks
	// committed and the reference writes in progress then finished.
	ReferencedGroupIDs map[string]struct{}
	Actor              SCIMEnforceActor
}

EnforceSCIMOptions holds what enforcing a SCIM connection needs from outside the gateway database.

type EnforceSCIMResult added in v0.27.0

type EnforceSCIMResult struct {
	Connection *types.SCIMConnection
	// DisabledUserIDs are the users disabled because SCIM never provisioned them.
	DisabledUserIDs []uint
	// DeletedGroupIDs are the unbound groups deleted because nothing referenced them.
	DeletedGroupIDs []string
}

EnforceSCIMResult is what enforcing a SCIM connection did.

type EnforcementDecisionOptions added in v0.25.0

type EnforcementDecisionOptions struct {
	MDMConfigurationID []uint
	Actor              []string // device_id
	Agent              []string
	Server             []string // server_name
	Tool               []string
	Kind               []string
	Decision           []string // allow | deny

	Query     string
	StartTime time.Time
	EndTime   time.Time
	Limit     int
	Offset    int
	SortBy    string
	SortOrder string
}

func (EnforcementDecisionOptions) Validate added in v0.25.0

func (o EnforcementDecisionOptions) Validate() error

Validate reports whether the caller-supplied sort inputs are acceptable. It is exported so the API layer can surface a bad sort key/direction as a 400 rather than letting it fall through to a 500.

type ExplicitRoleError added in v0.12.0

type ExplicitRoleError struct {
	// contains filtered or unexported fields
}

func (*ExplicitRoleError) Error added in v0.12.0

func (e *ExplicitRoleError) Error() string

type FetchUserGroupsError added in v0.15.0

type FetchUserGroupsError struct {
	ProviderUserID string
	Message        string
}

FetchUserGroupsError represents an error that occurs when fetching user groups from the auth provider. This error indicates a configuration issue with the auth provider that requires administrator intervention.

func (*FetchUserGroupsError) Error added in v0.15.0

func (e *FetchUserGroupsError) Error() string

type LLMAuditLogOptions added in v0.24.0

type LLMAuditLogOptions struct {
	WithSensitiveFields    bool
	HideModelsRequests     bool
	APIKeyID               []uint
	UserID                 []string
	ModelProvider          []string
	TargetModel            []string
	RequestPath            []string
	ResponseStatus         []int
	Outcome                []string
	UserAgent              []string
	ClientSessionID        []string
	MessagePolicyTriggered []bool
	Query                  string
	StartTime              time.Time
	EndTime                time.Time
	Limit                  int
	Offset                 int
	SortBy                 string
	SortOrder              string
}

type LastAdminError added in v0.5.0

type LastAdminError struct{}

func (*LastAdminError) Error added in v0.5.0

func (e *LastAdminError) Error() string

type LastOwnerError added in v0.13.0

type LastOwnerError struct{}

func (*LastOwnerError) Error added in v0.13.0

func (e *LastOwnerError) Error() string

type ListAuthGroupsOptions added in v0.25.2

type ListAuthGroupsOptions struct {
	NameFilter string
	Limit      int
	Cursor     string
}

type ListAuthGroupsResult added in v0.25.2

type ListAuthGroupsResult struct {
	Groups     []types.Group
	NextCursor string

	// Source is where the items came from: types.GroupSourceProvider or types.GroupSourceCache.
	Source types.GroupSource

	// Degraded is true when the auth provider could not be listed and the response fell back to
	// cached groups.
	Degraded bool

	// Reset is true when the supplied cursor could not be honored and these groups are the first
	// page of a fresh listing rather than the page that was asked for.
	Reset bool
}

type ListCredentialsOptions added in v0.23.0

type ListCredentialsOptions struct {
	CredentialContexts []string
	AllContexts        bool
}

type LogoutAllErr added in v0.8.0

type LogoutAllErr struct{}

func (LogoutAllErr) Error added in v0.8.0

func (e LogoutAllErr) Error() string

type MCPAuditLogOptions added in v0.8.0

type MCPAuditLogOptions struct {
	// WithRequestAndResponse requests decrypted payload and sensitive environment fields. It must
	// only be set after the caller has passed the corresponding authorization check.
	WithRequestAndResponse bool
	// SourceTypes selects the persisted source kinds. Empty preserves the MCP-only default.
	SourceTypes []types2.AuditLogSourceType
	// PowerUserWorkspaceID and OwnServerMCPIDs define the authorized MCP-server scope. When both
	// are present, a row may match either scope.
	PowerUserWorkspaceID []string
	OwnServerMCPIDs      []string
	// APIKeyID, UserID, SessionID, and ClientIP are common filters shared by both sources.
	APIKeyID  []uint
	UserID    []string
	SessionID []string
	ClientIP  []string
	// ProcessingTimeMin and ProcessingTimeMax filter the normalized duration field, using MCP
	// processing time or local-agent duration as appropriate.
	ProcessingTimeMin int64
	ProcessingTimeMax int64

	// MCP-only filters.
	MCPID                     []string
	MCPServerDisplayName      []string
	MCPServerCatalogEntryName []string
	CallType                  []string
	CallIdentifier            []string
	ClientName                []string
	ClientVersion             []string
	ResponseStatus            []string

	// Local-agent tool-call filters.
	AgentProvider []string
	Status        []string
	ToolName      []string
	ToolKind      []string
	DeviceID      []string

	// Unified, source-agnostic filters used by the audit log UI.
	//
	//   Actor     matches user_id OR device_id (users and enrolled devices).
	//   Operation matches MCP call_type; local-agent rows have the implicit operation tools/call.
	//   MCPServer matches MCP mcp_id/mcp_server_display_name, or a local-agent row's MCP parent.
	//   Tool      matches MCP call_identifier or a local-agent action_name.
	//   Outcome   matches the normalized outcome (success/failure/denied/timeout/unknown); MCP rows
	//             are classified from response_status/error the same way ClassifyMCPOutcome does.
	//   Client    matches MCP client_name or local-agent agent_provider.
	Actor     []string
	Operation []string
	MCPServer []string
	Tool      []string
	Outcome   []string
	Client    []string

	// Query searches the non-sensitive text columns of every selected source and matching user
	// display names.
	Query     string
	StartTime time.Time
	EndTime   time.Time
	Limit     int
	Offset    int
	// SortBy accepts timestamp, event_type, outcome, and duration for mixed queries. A single-source
	// query may additionally use that source's allowlisted storage columns.
	SortBy string
	// SortOrder accepts asc or desc. Empty defaults to descending.
	SortOrder string
}

MCPAuditLogOptions configures audit-row queries across MCP and local-agent catalogs. Common filters apply to every selected source. MCP-only and local-agent-only filters are mutually exclusive; ValidateAuditLogOptions enforces those rules before a query runs.

type MCPUsageStatsOptions added in v0.8.0

type MCPUsageStatsOptions struct {
	MCPID                      string
	PowerUserWorkspaceID       []string // Workspace filtering support (same as audit logs)
	OwnServerMCPIDs            []string // MCPIDs for user's own servers (union with PowerUserWorkspaceID)
	UserIDs                    []string
	MCPServerDisplayNames      []string
	MCPServerCatalogEntryNames []string
	StartTime                  time.Time
	EndTime                    time.Time
}

MCPUsageStatsOptions represents options for querying MCP usage statistics

type MessagePolicyViolationDirectionCounts added in v0.19.0

type MessagePolicyViolationDirectionCounts struct {
	UserMessage int64 `json:"userMessage"`
	ToolCalls   int64 `json:"toolCalls"`
}

type MessagePolicyViolationOptions added in v0.19.0

type MessagePolicyViolationOptions struct {
	UserID      []string
	PolicyID    []string
	Direction   []string
	ProjectID   []string
	ThreadID    []string
	Query       string
	StartTime   time.Time
	EndTime     time.Time
	Limit       int
	Offset      int
	SortBy      string
	SortOrder   string
	TimeGroupBy string // "user" or "policy" (default)
}

MessagePolicyViolationOptions represents options for querying policy violations.

type MessagePolicyViolationPolicyCount added in v0.19.0

type MessagePolicyViolationPolicyCount struct {
	PolicyID   string `json:"policyID"`
	PolicyName string `json:"policyName"`
	Count      int64  `json:"count"`
}

type MessagePolicyViolationStats added in v0.19.0

type MessagePolicyViolationStats struct {
	ByTime      []MessagePolicyViolationTimeBucket    `json:"byTime"`
	ByPolicy    []MessagePolicyViolationPolicyCount   `json:"byPolicy"`
	ByUser      []MessagePolicyViolationUserCount     `json:"byUser"`
	ByDirection MessagePolicyViolationDirectionCounts `json:"byDirection"`
}

MessagePolicyViolationStats holds the aggregated stats returned by GetMessagePolicyViolationStats.

type MessagePolicyViolationTimeBucket added in v0.19.0

type MessagePolicyViolationTimeBucket struct {
	Time     time.Time `json:"time"`
	Category string    `json:"category"`
	Count    int64     `json:"count"`
}

type MessagePolicyViolationUserCount added in v0.19.0

type MessagePolicyViolationUserCount struct {
	UserID string `json:"userID"`
	Count  int64  `json:"count"`
}

type SCIMAuthenticationError added in v0.27.0

type SCIMAuthenticationError struct{}

SCIMAuthenticationError reports a bearer token that does not authenticate the SCIM connection it was presented to, including any token presented to a connection that has none.

func (*SCIMAuthenticationError) Error added in v0.27.0

type SCIMConflictError added in v0.27.0

type SCIMConflictError struct {
	Message string
}

SCIMConflictError reports a SCIM write that conflicts with an existing resource.

func (*SCIMConflictError) Error added in v0.27.0

func (e *SCIMConflictError) Error() string

type SCIMConnectionExistsError added in v0.27.0

type SCIMConnectionExistsError struct {
	ConnectionID string
}

SCIMConnectionExistsError reports an attempt to create a second SCIM connection.

func (*SCIMConnectionExistsError) Error added in v0.27.0

func (e *SCIMConnectionExistsError) Error() string

type SCIMConnectionStateError added in v0.27.0

type SCIMConnectionStateError struct {
	State types.SCIMConnectionState
}

SCIMConnectionStateError reports a transition that the connection's state does not allow. Both transitions are permanent, so neither can be repeated or reversed.

func (*SCIMConnectionStateError) Error added in v0.27.0

func (e *SCIMConnectionStateError) Error() string

type SCIMDeletionRun added in v0.27.0

type SCIMDeletionRun struct {
	ID string
	// GroupIDs are the groups the deletion marked.
	GroupIDs []string
}

SCIMDeletionRun is one deletion of the unreferenced groups of a SCIM connection's auth provider. Only the deletion that marked a group deletes it.

type SCIMEnforceActor added in v0.27.0

type SCIMEnforceActor struct {
	UserID                uint
	AuthProviderNamespace string
	AuthProviderName      string
}

SCIMEnforceActor is the user asking to enforce SCIM, and the auth provider they signed in with.

type SCIMEnforceActorProblem added in v0.27.0

type SCIMEnforceActorProblem string

SCIMEnforceActorProblem says why a user may not enforce SCIM: they could not be known to sign in once it is enforced.

const (
	// SCIMEnforceActorOtherAuthProvider means the actor did not sign in through the connection's auth provider.
	SCIMEnforceActorOtherAuthProvider SCIMEnforceActorProblem = "otherAuthProvider"
	// SCIMEnforceActorNotSignedIn means the actor has no identity of the connection's auth provider that has signed
	// in.
	SCIMEnforceActorNotSignedIn SCIMEnforceActorProblem = "notSignedIn"
	// SCIMEnforceActorUnprovisioned means the connection has not provisioned the actor.
	SCIMEnforceActorUnprovisioned SCIMEnforceActorProblem = "unprovisioned"
	// SCIMEnforceActorDeactivated means the identity provider deactivated the actor.
	SCIMEnforceActorDeactivated SCIMEnforceActorProblem = "deactivated"
	// SCIMEnforceActorDisabled means the actor is disabled or deleted in Obot.
	SCIMEnforceActorDisabled SCIMEnforceActorProblem = "disabled"
)

type SCIMEnforceBlockedError added in v0.27.0

type SCIMEnforceBlockedError struct {
	// UnboundGroups are the referenced groups that the identity provider has not pushed.
	UnboundGroups []SCIMProviderGroup
	// ActorProblem says why the acting user may not enforce SCIM, and is empty when they may.
	ActorProblem SCIMEnforceActorProblem
}

SCIMEnforceBlockedError reports why a SCIM connection cannot be enforced yet. Enforcing clears its marks for deletion when it is blocked.

func (*SCIMEnforceBlockedError) Error added in v0.27.0

func (e *SCIMEnforceBlockedError) Error() string

type SCIMGroup added in v0.27.0

type SCIMGroup struct {
	ID string
	// GroupID is the ID of the Obot group the SCIM group is bound to.
	GroupID     string
	DisplayName string
	// Members is nil unless members were requested.
	Members   []SCIMGroupMember
	Revision  int64
	CreatedAt time.Time
	UpdatedAt time.Time
}

SCIMGroup is a SCIM group as the SCIM endpoint serves it.

type SCIMGroupFilter added in v0.27.0

type SCIMGroupFilter struct {
	ID          string
	DisplayName string
}

SCIMGroupFilter selects SCIM groups. Empty fields match everything.

type SCIMGroupInput added in v0.27.0

type SCIMGroupInput struct {
	DisplayName string
	// MemberIDs are the SCIM user IDs of the complete member set.
	MemberIDs []string
}

SCIMGroupInput holds the writable attributes of a SCIM group, as a create or a full replacement sends them.

type SCIMGroupMember added in v0.27.0

type SCIMGroupMember struct {
	ID       string
	UserName string
}

SCIMGroupMember is a bound user in a SCIM group.

type SCIMGroupPatch added in v0.27.0

type SCIMGroupPatch struct {
	// DisplayName renames the group unless it is empty.
	DisplayName string
	// ReplaceMembers makes MemberIDs the complete member set. Otherwise, the users in MemberIDs are added, those in
	// RemovedMemberIDs are removed, and other members are not touched. All are SCIM user IDs.
	ReplaceMembers   bool
	MemberIDs        []string
	RemovedMemberIDs []string
}

SCIMGroupPatch changes a bound group by naming the members it adds and removes, rather than its complete member set, so that applying it never reads the group's other members.

type SCIMGroupReference added in v0.27.0

type SCIMGroupReference struct {
	ID          string
	DisplayName string
}

SCIMGroupReference names a bound group.

type SCIMGroupReferenceError added in v0.27.0

type SCIMGroupReferenceError struct {
	AuthProviderNamespace string
	AuthProviderName      string
	// Missing are group IDs that no group of the provider has.
	Missing []string
	// PendingDeletion are groups that are being deleted.
	PendingDeletion []string
}

SCIMGroupReferenceError reports new references to groups that a SCIM connection's auth provider cannot use: group IDs with the connection's group ID prefix that no group of the provider has, and groups that are being deleted because nothing referenced them.

func (*SCIMGroupReferenceError) Error added in v0.27.0

func (e *SCIMGroupReferenceError) Error() string

type SCIMInvalidValueError added in v0.27.0

type SCIMInvalidValueError struct {
	Message string
}

SCIMInvalidValueError reports a SCIM write whose values cannot be applied.

func (*SCIMInvalidValueError) Error added in v0.27.0

func (e *SCIMInvalidValueError) Error() string

type SCIMManagedUserError added in v0.27.0

type SCIMManagedUserError struct {
	UserID  uint
	Message string
}

SCIMManagedUserError reports an Obot-side change that is refused because SCIM manages the user.

func (*SCIMManagedUserError) Error added in v0.27.0

func (e *SCIMManagedUserError) Error() string

type SCIMMutabilityError added in v0.27.0

type SCIMMutabilityError struct {
	Message string
}

SCIMMutabilityError reports a SCIM write that changes an attribute that cannot change.

func (*SCIMMutabilityError) Error added in v0.27.0

func (e *SCIMMutabilityError) Error() string

type SCIMNotFoundError added in v0.27.0

type SCIMNotFoundError struct {
	ResourceType types.SCIMResourceType
	ID           string
}

SCIMNotFoundError reports a SCIM resource that does not exist in the connection. Retired resources and resources that are not bound are reported the same way.

func (*SCIMNotFoundError) Error added in v0.27.0

func (e *SCIMNotFoundError) Error() string

type SCIMPage added in v0.27.0

type SCIMPage struct {
	Offset int
	Limit  int
}

SCIMPage selects a page of results. Offset is zero-based. A zero Limit returns only the total.

type SCIMProviderGroup added in v0.27.0

type SCIMProviderGroup struct {
	ID   string
	Name string
	// SCIMID is the ID of the group's unretired SCIM binding. It is empty while the group is unbound.
	SCIMID string `gorm:"column:scim_id"`
	// PendingDeletion is set while the group is marked for deletion because nothing references it.
	PendingDeletion bool `gorm:"column:pending_deletion"`
	// PendingRunID identifies the deletion that marked the group.
	PendingRunID string `gorm:"column:pending_run_id"`
}

SCIMProviderGroup is a group of an auth provider, with its SCIM binding if it has one.

type SCIMRequestOutcome added in v0.27.0

type SCIMRequestOutcome struct {
	Method   string
	Resource string
	Status   int
	SCIMType string
	Detail   string
}

SCIMRequestOutcome describes a handled SCIM request.

type SCIMResidualGroupDataError added in v0.27.0

type SCIMResidualGroupDataError struct {
	AuthProviderName string
	Data             AuthProviderGroupData
}

SCIMResidualGroupDataError reports that a SCIM connection was not created, because its auth provider still has group data from an earlier configuration. The provider's auth provider cleanup removes it.

func (*SCIMResidualGroupDataError) Error added in v0.27.0

type SCIMSetupUser added in v0.27.0

type SCIMSetupUser struct {
	UserID         uint
	Username       string
	Email          string
	DisplayName    string
	DisabledAt     *time.Time
	DisabledReason types.UserDisabledReason
	// SCIMID is the ID of the user's unretired SCIM binding. It is empty while the user is unprovisioned.
	SCIMID string
	// Active is the provisioned state the identity provider last sent.
	Active bool
	// SignedIn is set once the user has signed in through the connection's auth provider.
	SignedIn bool
}

SCIMSetupUser is a user of a SCIM connection's auth provider.

type SCIMUser added in v0.27.0

type SCIMUser struct {
	ID         string
	UserID     uint
	UserName   string
	ExternalID string
	Active     bool
	Profile    types.SCIMUserProfile
	// Groups are the bound groups the user is a direct member of.
	Groups    []SCIMGroupReference
	Revision  int64
	CreatedAt time.Time
	UpdatedAt time.Time
}

SCIMUser is a SCIM user as the SCIM endpoint serves it.

type SCIMUserCreateOptions added in v0.27.0

type SCIMUserCreateOptions struct {
	UserLimit UserLimit
	// DefaultRole is the role of users that SCIM creates.
	DefaultRole types2.Role
}

SCIMUserCreateOptions holds what a SCIM user create needs from outside the gateway database.

type SCIMUserFilter added in v0.27.0

type SCIMUserFilter struct {
	ID       string
	UserName string
}

SCIMUserFilter selects SCIM users. Empty fields match everything.

type SCIMUserInput added in v0.27.0

type SCIMUserInput struct {
	UserName   string
	ExternalID string
	// Active is the provisioned state. Nil means active on a create, and keeps the current state on a replacement.
	Active  *bool
	Profile types.SCIMUserProfile
}

SCIMUserInput holds the writable attributes of a SCIM user, as a create or a full replacement sends them.

type SkillStatListOptions added in v0.22.0

type SkillStatListOptions struct {
	StartTime time.Time
	EndTime   time.Time
	Name      string // case-insensitive LIKE match against skill name
	SortBy    string // name | device_count | user_count | observation_count
	SortOrder string // asc | desc
	Limit     int
	Offset    int
}

SkillStatListOptions filters and orders the paginated skill stats list. The time window applies to the parent device_scans (only scans inside the window are candidates for "latest per device" selection). Zero-valued bounds are treated as unbounded.

type UserAccessDeniedError added in v0.27.0

type UserAccessDeniedError struct {
	UserID uint
	Status types2.UserStatus
}

UserAccessDeniedError reports that a user may not access Obot because they are disabled, deleted, or missing.

func (*UserAccessDeniedError) Error added in v0.27.0

func (e *UserAccessDeniedError) Error() string

func (*UserAccessDeniedError) HTTPError added in v0.27.0

func (e *UserAccessDeniedError) HTTPError() *types2.ErrHTTP

HTTPError returns the response for a request denied by this error.

type UserAccessLookupError added in v0.27.0

type UserAccessLookupError struct {
	UserID uint
	Err    error
}

UserAccessLookupError reports that a user's lifecycle status could not be determined. Callers must deny access, and must not fall back to another credential or to anonymous access.

func (*UserAccessLookupError) Error added in v0.27.0

func (e *UserAccessLookupError) Error() string

func (*UserAccessLookupError) Unwrap added in v0.27.0

func (e *UserAccessLookupError) Unwrap() error

type UserDecorator

type UserDecorator struct {
	// contains filtered or unexported fields
}

func NewUserDecorator

func NewUserDecorator(next authenticator.Request, client *Client, userLimitProvider UserLimitProvider) *UserDecorator

func (UserDecorator) AuthenticateRequest

func (u UserDecorator) AuthenticateRequest(req *http.Request) (*authenticator.Response, bool, error)

type UserDeletedError added in v0.27.0

type UserDeletedError struct {
	UserID uint
}

UserDeletedError reports a lifecycle change for a deleted user. Deleted users stay deleted.

func (*UserDeletedError) Error added in v0.27.0

func (e *UserDeletedError) Error() string

type UserLimit added in v0.25.0

type UserLimit struct {
	Maximum   int64
	Unlimited bool
}

UserLimit describes the maximum number of users an installation may have. Maximum is ignored when Unlimited is true.

type UserLimitProvider added in v0.25.0

type UserLimitProvider interface {
	UserLimit(context.Context) (UserLimit, error)
}

UserLimitProvider resolves the current license-derived user limit.

type UserOutsideAuthProviderError added in v0.27.0

type UserOutsideAuthProviderError struct {
	UserID   uint
	Provider AuthProviderRef
}

UserOutsideAuthProviderError reports a lifecycle change for a user with no identity for the auth provider making the change. Lifecycle changes never reach users of other auth providers.

func (*UserOutsideAuthProviderError) Error added in v0.27.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL