First sign-in and access control

The first administrator, local accounts with TOTP, LDAP and Active Directory, OpenID Connect, API tokens, roles, and grants scoped by NetBox site, tenant and tag.

On this page

Status. Tested: local passwords, lockout, TOTP and recovery codes, sessions, API tokens, OpenID Connect against an in-process provider, LDAP against an in-process directory, roles, grants, scopes and the scope check over every mounted route, in the product's package tests on PostgreSQL. Not yet run: sign-in through a third-party identity provider, a real LDAP directory, or Active Directory.

First sign-in

The first administrator is created at start from STRUCTAM_BOOTSTRAP_ADMIN_USER (default admin) and STRUCTAM_BOOTSTRAP_ADMIN_PASSWORD (or its _FILE form), only while the database has no users at all. The password must pass the password policy, or the server does not start, and it must be changed at the first sign-in. Remove it from the environment afterwards.

Without a bootstrap password (on Kubernetes, for example), create the administrator on a server:

structam user create -username admin -admin           # prints a temporary password, changed at first sign-in

Then:

  1. Change the password, and set up TOTP under Account.
  2. Create accounts for people, or connect a directory or an identity provider (below).
  3. Give access with role grants (Access). Use scoped grants for teams that should see only part of the estate.

Break-glass from a server, whatever the state of the database's users: structam user create -username NAME -admin, structam user reset-password -username NAME and structam user unlock -username NAME.

Who can sign in

PrincipalSigns in withNotes
Person, localusername and password, plus TOTPArgon2id; 12 or more characters, not a common password, not containing the username
Person, LDAP or Active Directorydirectory username and passwordbind and search; directory groups mapped to local groups
Person, OpenID Connectthe identity providerseveral providers; authorization code with PKCE and nonce
Service usernothingowns API tokens; has no password
API tokenAuthorization: Bearer stt_...owned by a user; never accepted in a URL

Local accounts

  • Passwords are stored with Argon2id (64 MiB, 3 iterations, parallelism 2).
  • Lockout: 10 failed sign-ins in 15 minutes lock the name. Failures are counted in the database, so across nodes, and for names that do not exist, so the lockout reveals nothing. Unlock on Access → Users or with structam user unlock.
  • Rate limits: 30 sign-ins a minute per client address (IPv6 per /64) and 20 per typed name, across nodes. Unknown, disabled and locked accounts answer exactly like a wrong password and take as long.
  • TOTP (RFC 6238, 6 digits, 30 s) with 10 single-use recovery codes, set up under Account. A code is refused once used. STRUCTAM_REQUIRE_TOTP=on (or Access → Sign-in → Sign-in policy) makes every local account enrol before it can do anything else; it can also be required per user.
  • Re-authentication: creating a token, changing a password and changing TOTP or recovery codes need a sign-in within the last 10 minutes.
  • STRUCTAM_LOCAL_LOGIN=break-glass: while an OpenID Connect provider is enabled, local passwords work only for administrators, and the sign-in page hides the form unless opened with ?local=1.

Sessions

The session cookie is __Host-structam_session (Secure, HttpOnly, SameSite=Lax), stored as a SHA-256 hash, with a sliding idle limit of 12 h and an absolute limit of 7 days (the sign-in policy may shorten both). Only use extends the idle limit: background polling and the event stream do not, so a tab left open still signs out.

Signing in always issues a new session. A password change or reset, a TOTP reset, or disabling or deleting a user ends the user's other sessions at once on every node, including open event streams. Grant changes take effect within 5 s without ending sessions. The Account page lists and ends your own sessions.

LDAP and Active Directory

Set STRUCTAM_LDAP_* (configuration reference) or save the setting on Access → Sign-in → Directory.

  • Use ldaps://, or ldap:// with STRUCTAM_LDAP_START_TLS=on; plain LDAP is refused, because binds carry passwords. Certificates are always verified (STRUCTAM_LDAP_CA_FILE adds a private CA).
  • A saved bind password is only sent to the URLs and CA bundle it was saved with: changing either needs the password again.
  • Groups come from memberOf or a group search; STRUCTAM_LDAP_NESTED_GROUPS=on uses Active Directory's in-chain matching rule.
  • Accounts bind to the directory entry's stable id (objectGUID, entryUUID, else the case-folded DN), never to the typed name, and never to an existing local account.
  • Directory groups become memberships of local groups through directory group mappings (Access → Groups), at each sign-in and at each directory sync (every STRUCTAM_LDAP_SYNC_INTERVAL, 15 minutes by default).
  • With STRUCTAM_LDAP_REQUIRE_GROUP=on (the default) a user none of whose groups is mapped cannot sign in.
  • A directory error refuses the sign-in; it never falls back to a default role.
  • When a person's directory entry is deleted, the next sync removes the memberships the directory gave them and ends their sessions, so their API tokens lose that access too. Grants an administrator gave by hand stay, and the account stays enabled until an administrator disables or deletes it.

OpenID Connect

One setting per provider (Access → Sign-in → Single sign-on), or STRUCTAM_OIDC_PROVIDERS plus STRUCTAM_OIDC_<SLUG>_* (configuration reference). Register this redirect URI at the provider:

https://structam.example.com/api/v1/auth/oidc/<slug>/callback
  • Identities bind on provider, issuer and subject. An OpenID Connect identity never attaches to a local or LDAP account: a provider can never take over an existing account.
  • With JIT=on (the default) an account is created at first sign-in, with no grants unless one of its groups (the groups claim by default) is mapped; REQUIRE_GROUP=on refuses users none of whose groups is mapped.

API tokens

A token is stt_ followed by 32 random bytes, stored as a SHA-256 hash and shown once.

  • A token has its own role grants, and optionally an expiry and source CIDRs. Its permission on a host is its own grants intersected with its owner's current grants, recomputed on every request, so a token never exceeds its owner and stops working when the owner is disabled.
  • Tokens cannot call /auth/* or /account/*, and cannot create tokens. They cannot use Ask AI.
  • Users create their own tokens under Account; administrators under Access → API tokens. Only structam token create on a server can give a token a role with users.manage or *.

Token scopes allow what roles do not, and the export scope gates exports a role would otherwise allow:

ScopeAllowsA user may give it with
ingestPOST /api/v1/ingest/infradb-audit (InfraDB's audit sink)integrations.manage
metricsGET /metrics and GET /metrics/federate on the main listenersystem.manage
taxiithe TAXII 2.1 serverview
exportexports, besides each route's permission: the estate CSV, report CSVs, configuration exports, the audit exportinventory.export

A token owned by a person uses a scope only while that person holds the permission in the last column, checked on every request. A token owned by a service user keeps its scopes whatever the service user holds: use one for integrations, so the token does not depend on a person's role.

structam user create -username siem-svc -service -role viewer
structam token create -name taxii-reader -owner siem-svc -role viewer -scopes taxii

Permissions and roles

A role is a named set of permissions. Built-in roles cannot be deleted or renamed; custom roles can hold any permission except *.

Permissions

The catalogue GET /api/v1/meta returns. Scoped permissions may be granted for a set of sites, tenants and tags; the others only unscoped.

PermissionAreaMeaningScoped
viewInventoryRead hosts, inventory, change metadata, config metadata and redacted config content.yes
configs.contentConfigurationsRead raw configuration content, diffs and exports.yes
changes.reviewChangesApprove, reject and comment on change events; set config baselines.yes
inventory.exportInventoryCSV and JSON exports and config snapshots.yes
assets.editInventoryITAM fields, host notes and software entitlements.yes
agents.manageAgentsRevoke, update, collect now, fetch config, match unmatched agents.yes
agents.enrolAgentsCreate join tokens and onboarding tokens.yes
policies.manageAgentsAgent policies and assignments, change rules.no
assistant.useAssistantUse the assistant; its tools see only the user’s scope.yes
audit.viewAuditAudit log and chain verification.no
integrations.manageIntegrationsNetBox, InfraDB, LLM, SIEM sinks, TAXII and discovery.no
users.manageAccessUsers, groups, roles, grants, tokens, SSO and LDAP settings.no
system.manageSystemLicence, nodes, queues, retention and maintenance.no
*SystemEvery permission, unscoped.no

Built-in roles

Their permissions can be edited; the roles cannot be deleted or renamed.

RolePermissions
viewerview
auditorview, configs.content, inventory.export, audit.view
reviewerview, configs.content, changes.review
operatorview, configs.content, changes.review, inventory.export, assets.edit, agents.manage, assistant.use
admin*

Grants and scope

A grant gives a role to a user, a group or a token, either unscoped (every host) or scoped to a set of NetBox sites, tenants and tags:

{"subject_type": "group", "subject_id": 7, "role": "operator",
 "scope": {"sites": ["dc1", "dc2"], "tenants": [], "tags": ["structam-pci"]}}
  • A host matches a scope when its site, or its tenant, or any of its tags is listed. Several grants add up.
  • Only tags starting with STRUCTAM_RBAC_TAG_PREFIX (default structam-) may be used in a scope.
  • Unmatched hosts (agents on hosts NetBox does not know yet) are visible only through unscoped grants.
  • Permissions marked "not scoped" above count only from unscoped grants.
  • A host outside your scope answers 404, exactly as if it did not exist. Lists, estate views, reports, exports, the event stream, TAXII and every Ask AI tool are filtered the same way, in SQL. Routes that touch two hosts (a diff between hosts, matching an agent to a host) check both. A product test enumerates every mounted route and fails on host data without a scope check.

Caution. NetBox decides scoped access. Site, tenant and tags come from NetBox, so whoever can set them on a device in NetBox decides which scoped Structam users see it. Keep the structam- tags, and the sites and tenants you scope by, under NetBox permissions you trust.

users.manage can grant anything, * included: it is the root of access and is only held unscoped. A change that would leave no enabled person with an unscoped * grant is refused (409 last_admin); structam user create -admin on a server stays the break-glass.

Request protection

  • The API is same-origin only: there is no CORS.
  • A request that changes something with a session cookie must be JSON and carry an Origin equal to the public URL's origin (or one listed in STRUCTAM_ALLOWED_ORIGINS).
  • A request with Authorization is judged by it alone; a bad bearer token is 401, never a cookie fallback.
  • Every mutating request that nothing else audited is recorded as api.request; refused requests (401, 403) are recorded too, at most once per client, route and outcome every 30 s.
  • The client address used for rate limits, token CIDRs and the audit log is the socket address, or the right-most X-Forwarded-For entry that is not a trusted proxy when the peer is listed in STRUCTAM_TRUSTED_PROXIES.

Questions the docs do not answer?

Ask the people who build Structam. Installation media and licences come from KazLabs.

Talk to us