zynactradocs

Configuration

Every option of Access, the guard, the access API and the Nest module, and the environment variables tests read.

Access

Go (access.Config)TypeScript (AccessConfig)Default
ManifestmanifestrequiredThe compiled manifest (accessgen.Manifest, parseManifest(...)).
Cerboscerbosrequiredaccess.NewCerbosHTTP(url) / new CerbosHTTP(url).
Storestorerequiredsqlstore.New(db) / new PgStore(pool).
Resolverresolverno-opPrincipal attributes and set expansion. A no-op resolver switches prefix grants off and expands nothing.
CacheTTLcacheTtlMs60 sHow long a subject's grants are cached. Negative disables the cache.
CacheSizecacheSize10000Subjects cached.
TimeouttimeoutMs250 msPer Cerbos call; each call retries once.
StrictstrictoffProgrammer errors become invalid errors. Turn on in development and tests.
Loggerloggerslog.Default() / console
Nownowthe clockFor tests.

Route guard (Go)

accesshttp.Guard:

Field
AccessThe *access.Access.
StrictA guarded route that returns success without checking its permission against a record fails with 500. Responses are buffered to make that possible.
LoggerWhere missing checks are logged when Strict is off.

Access API (Go)

accesshttp.Config for accesshttp.Handler:

FieldDefault
ServicerequiredThe *admin.Service.
LoadersnoneRecord loaders by kind, for /check and /explain. A kind without one is refused with 400.
MaxChecks100Most items in one /check.
Loggerslog.Default()

Nest module

AccessModule.forRoot(options):

OptionDefault
accessrequiredThe Access instance.
subject(req)requiredReads the authenticated subject; return undefined when there is none.
adminnoneWith an AdminService, the access API is served.
path"access"Where the API is served.
loadersnoneRecord loaders by kind.
strictfalseStrict requirement tracking. Don't use @Res() on guarded routes.
denyUndeclaredtrueDeny routes with no access decorator.
globaltrueRegister the guard, interceptor and filter globally.
maxChecks100Most items in one /check.
loggerconsole

forRootAsync({ useFactory, inject, path, api? }) takes the same options from a factory; path is fixed at import time because Nest needs controller paths early.

React client

createAccessClient(options):

OptionDefault
baseUrl"/access"Where the API is mounted.
headers()noneExtra headers per request, such as Authorization. May be async.
credentials"same-origin"Passed to fetch.
fetchglobalThis.fetchFor tests (fakeAccessApi) and custom transports.

Environment variables for tests

Variable
ACCESS_TEST_DATABASE_URLA Postgres the test helpers can create and drop databases on.
CERBOS_BINThe cerbos binary, when it isn't on PATH.
ACCESS_REQUIRE_LIVE=1Fail, instead of skip, tests that need Postgres or Cerbos. Set it in CI.
Edit on GitHub

On this page