mirror of
https://github.com/dsx-ai-factory/nvke.git
synced 2026-12-07 04:35:58 +08:00
An API describes each request as a Target, the action and the resource it acts on, and calls Client.Check. Check reads the caller from the authN principal, asks the backend, counts the decision, logs a refusal, and on an allow returns a context carrying the authorized Caller. Route resolution stays in each API. A missing object gets ErrNotFound without asking the backend: the answer a caller with a tenant gets for another tenant's object, so an ID doesn't reveal whether an object exists. Every existing object must have an owner tenant. NewClient takes a logger and a Recorder, either of which may be nil. A Recorder counts every decision, with OutcomeError for a request that couldn't be decided. Authorize becomes internal: an API never builds a Query or reads a Decision. ListTenant returns the tenant a list must be filtered to, or all tenants for an operator. On an error it returns no tenant and not all, so a caller that drops the error lists nothing. WriteError answers a refusal over HTTP: 403, 404 with no body, or 500, with a fixed body that never carries error text. authN and authZ share that writer, and authN's responses are unchanged. Signed-off-by: dbudris <dbudris@nvidia.com>