Documentation
¶
Overview ¶
Package api glues the storage primitives behind the Privasys Drive REST surface. The handlers are intentionally thin — every operation has a matching public function in the underlying packages so the manifest-tool surface (tools.go) can call them directly without going through HTTP.
Index ¶
- Variables
- type MEKProvider
- type Principal
- type SealedBucketCred
- type Server
- func (s *Server) CurrentConfig() *config.Config
- func (s *Server) Handler(manifestPath string) http.Handler
- func (s *Server) InstallConfig(c *config.Config)
- func (s *Server) Notifier() *notify.Client
- func (s *Server) Routes() http.Handler
- func (s *Server) SetConfig(c *config.Config) error
- func (s *Server) StartExpirySweep(ctx context.Context, interval time.Duration)
- func (s *Server) StartIndexer()
- func (s *Server) Tools() http.Handler
- func (s *Server) WaitBackground()
- type WorkspaceFile
- type WorkspaceManifest
Constants ¶
This section is empty.
Variables ¶
var ErrVaultKeyStale = errors.New("tenant vault key unavailable; re-arm via POST /v1/me/tenant/key")
ErrVaultKeyStale means the tenant's vault MEK could not be loaded (typically the stored attestation token expired since the last re-arm). It is recoverable: the owner re-arms via POST /v1/me/tenant/key with a fresh grant bundle. Callers surface it as 409 with a machine-readable code so a client auto-re-arms rather than treating it as a hard failure.
Functions ¶
This section is empty.
Types ¶
type MEKProvider ¶
type MEKProvider interface {
Provision(ctx context.Context, b vaultmek.Bundle) (vaultmek.Ref, error)
Load(ctx context.Context, ref vaultmek.Ref) ([]byte, error)
Unwrap(ctx context.Context, ref vaultmek.Ref, ciphertext, iv []byte) ([]byte, error)
// RefreshTees is the data owner's measurement approval: replace the
// key's pinned TEE profile with the grant's (the app's current
// measurement), authenticated as the key owner.
RefreshTees(ctx context.Context, ref vaultmek.Ref, grant, ownerBearer string) error
// Regenerate re-creates the tenant's key (same material) at the next
// handle generation under a fresh grant — the renewal for the vault's
// fixed expires_at, and the ride off a retiring constellation.
Regenerate(ctx context.Context, ref vaultmek.Ref, b vaultmek.Bundle) (vaultmek.Ref, error)
}
MEKProvider is the vault-side of per-tenant keys and sealed credentials (vaultmek.Client in production; faked in tests).
type Principal ¶
type Principal struct {
Sub string
Via authVia
ID *oidc.Identity // non-nil for users
Grant *grants.Grant // non-nil for app principals
Env *grants.Envelope // non-nil for app principals
// Bearer is the caller's raw platform token, kept for the bearer
// path alone. Funding a recipient's attribute disclosure is an act
// the control plane attributes to the caller's OWN account, which it
// resolves from the token, so Drive has to present the caller's
// token rather than its app identity. Empty on every other path,
// which is why a sealed-session sharer cannot fund a share.
Bearer string
// AIGrant marks an assistant principal that came from a files.ai grant
// rather than the trusted assistant enclave: it acts for the holder who
// minted the grant, may read and search their AI scope, and nothing more
// (no open_link, no settings changes).
AIGrant bool
}
Principal is an authenticated caller: a platform user (OIDC bearer or sealed-transport session) or a third-party app presenting an AppGrant token.
func (*Principal) IsAssistant ¶
IsAssistant reports whether p is the confidential-AI assistant enclave acting on behalf of a user (§8.7 RAG-in-enclave). Such a principal may run only the AI-scoped RAG surface: it reads the tenant's AI-scoped node set and the shares the user opened through it, and its one act is open_link, which gives the user what clicking the link would (assistantshares.go). It never writes content.
type SealedBucketCred ¶
type SealedBucketCred struct {
// KeyRef addresses the operator key on the constellation (handle,
// endpoints, MRENCLAVE, attestation server + token).
KeyRef vaultmek.Ref `json:"key_ref"`
// CiphertextB64 / IvB64 are the sealed credential (raw-url base64).
CiphertextB64 string `json:"ciphertext_b64"`
IvB64 string `json:"iv_b64"`
// ContentType labels the credential for the object backend
// (e.g. "gcs-sa-json", "s3-keypair", "ovh-token").
ContentType string `json:"content_type"`
// Bucket is the target bucket name (plaintext metadata, not secret);
// the sealed plaintext holds only the credential material.
Bucket string `json:"bucket"`
}
SealedBucketCred is a BYO cloud-bucket credential a tenant sealed under a vault "wrapped-secret" operator key (an Aes256GcmKey whose policy grants Drive's app TEE Unwrap only — never Wrap or DeleteKey). The tenant/owner sealed the plaintext with an in-enclave Wrap RPC to the vault; Drive stores only the ciphertext and unwraps it in-enclave per session, so the platform, the operator and a non-promoted build never see the credential.
type Server ¶
type Server struct {
Store *store.Store
Backend objectstore.Backend
Grants *grants.Repo
Verifier oidc.Verifier
MEK []byte // single tenant MEK for `--dev`. Production: fetched per tenant from vault.
// Revoked rejects tokens whose IdP session was revoked (long-lived
// API keys). Nil disables the check.
Revoked *oidc.RevokedSet
// AttrRef reads the IdP's canonical attribute referential, which is
// what tells a government-backed attribute key from the self-asserted
// twin that answers the same question for free. Nil where no issuer is
// configured, which is fail-closed everywhere an attribute can be
// billed: a share requiring one is refused rather than stored at an
// assurance nobody chose.
AttrRef *attrref.Client
// MEKs provisions and loads per-tenant vault-held MEKs. Nil
// disables vault-held tenant keys (tenants stay on the instance
// MEK).
MEKs MEKProvider
// Platform is the enclave-manager environment (empty off-platform).
Platform platform.Env
// StateDir persists the instance config (the sealed /data volume on
// the platform).
StateDir string
// DevMode relaxes the configure-authz role check (dev verifier runs
// without platform roles).
DevMode bool
Version string
// WebDir holds the UI's static export (webui.go); empty serves the API
// only.
WebDir string
// contains filtered or unexported fields
}
Server bundles the handlers + their dependencies.
func (*Server) CurrentConfig ¶
CurrentConfig returns the active config, or nil before configure.
func (*Server) Handler ¶
Handler returns the full HTTP surface: health/status/configure, the REST API under /v1, the manifest tools under /tools, and the manifest document endpoints.
func (*Server) InstallConfig ¶
InstallConfig sets the in-memory config without persisting (boot-time re-apply of an already-persisted config).
func (*Server) Notifier ¶
Notifier returns the wallet-push client, building it lazily from the current config's control-plane base URL and the app's manager-minted identity. Nil when either is unavailable (off-platform / unconfigured): notifications degrade to silence, never to an error.
func (*Server) StartExpirySweep ¶
StartExpirySweep runs the session-attachment GC (§8.7 intent A): every interval it deletes nodes whose expiry has passed, cascading their index rows. Stops when ctx is cancelled. Safe to call once at boot.
func (*Server) StartIndexer ¶
func (s *Server) StartIndexer()
StartIndexer starts the background indexer's worker and retry sweep at boot. Without this, the sweep only starts on the first post-boot upload (Enqueue), and a restarted deployment with a backlog but no new uploads never drains its queue. No-op without pgvector (SQLite dev, CI).
func (*Server) Tools ¶
Tools returns the manifest-tool invocation surface: the plain-JSON POST endpoints the privasys.json tools point at. Each is a thin wrapper over the same internals as the REST surface, with identical auth (OIDC bearer or AppGrant) and access checks.
func (*Server) WaitBackground ¶
func (s *Server) WaitBackground()
WaitBackground blocks until in-flight background writes (access metrics) have drained. Call before closing the store.
type WorkspaceFile ¶
type WorkspaceFile struct {
Path string `json:"path"`
Size int64 `json:"size"`
Mode string `json:"mode,omitempty"`
Blob string `json:"blob"`
}
WorkspaceFile is one entry of a workspace manifest.
type WorkspaceManifest ¶
type WorkspaceManifest struct {
Version int `json:"version"`
App string `json:"app,omitempty"`
SavedAt string `json:"saved_at,omitempty"`
Files []WorkspaceFile `json:"files"`
}
WorkspaceManifest is the snapshot description the runtime writes.
Source Files
¶
- aiscope.go
- api.go
- appfolders.go
- assistantshares.go
- attributes.go
- backend.go
- bucketcred.go
- capabilities.go
- capabilities_holder.go
- configure.go
- conversations.go
- diff.go
- digest.go
- disclosure.go
- download.go
- drain.go
- escrow.go
- foldertree.go
- graph.go
- indexing.go
- knowledge.go
- links.go
- linktools.go
- mcp.go
- mcpsettings.go
- me.go
- members.go
- memory.go
- move.go
- ownerapproval.go
- permissions.go
- purge.go
- recovery.go
- rekey.go
- searchtools.go
- sharing.go
- spend.go
- subtree.go
- tenantkey.go
- tenantkeysweep.go
- tierb.go
- tierb2.go
- tools.go
- uploads.go
- versions.go
- webui.go
- workspace.go