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-inThen:
- Change the password, and set up TOTP under Account.
- Create accounts for people, or connect a directory or an identity provider (below).
- 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
| Principal | Signs in with | Notes |
|---|---|---|
| Person, local | username and password, plus TOTP | Argon2id; 12 or more characters, not a common password, not containing the username |
| Person, LDAP or Active Directory | directory username and password | bind and search; directory groups mapped to local groups |
| Person, OpenID Connect | the identity provider | several providers; authorization code with PKCE and nonce |
| Service user | nothing | owns API tokens; has no password |
| API token | Authorization: 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://, orldap://withSTRUCTAM_LDAP_START_TLS=on; plain LDAP is refused, because binds carry passwords. Certificates are always verified (STRUCTAM_LDAP_CA_FILEadds 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
memberOfor a group search;STRUCTAM_LDAP_NESTED_GROUPS=onuses 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 (thegroupsclaim by default) is mapped;REQUIRE_GROUP=onrefuses 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 createon a server can give a token a role withusers.manageor*.
Token scopes allow what roles do not, and the export scope gates exports a role would otherwise allow:
| Scope | Allows | A user may give it with |
|---|---|---|
ingest | POST /api/v1/ingest/infradb-audit (InfraDB's audit sink) | integrations.manage |
metrics | GET /metrics and GET /metrics/federate on the main listener | system.manage |
taxii | the TAXII 2.1 server | view |
export | exports, besides each route's permission: the estate CSV, report CSVs, configuration exports, the audit export | inventory.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 taxiiPermissions 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.
| Permission | Area | Meaning | Scoped |
|---|---|---|---|
view | Inventory | Read hosts, inventory, change metadata, config metadata and redacted config content. | yes |
configs.content | Configurations | Read raw configuration content, diffs and exports. | yes |
changes.review | Changes | Approve, reject and comment on change events; set config baselines. | yes |
inventory.export | Inventory | CSV and JSON exports and config snapshots. | yes |
assets.edit | Inventory | ITAM fields, host notes and software entitlements. | yes |
agents.manage | Agents | Revoke, update, collect now, fetch config, match unmatched agents. | yes |
agents.enrol | Agents | Create join tokens and onboarding tokens. | yes |
policies.manage | Agents | Agent policies and assignments, change rules. | no |
assistant.use | Assistant | Use the assistant; its tools see only the user’s scope. | yes |
audit.view | Audit | Audit log and chain verification. | no |
integrations.manage | Integrations | NetBox, InfraDB, LLM, SIEM sinks, TAXII and discovery. | no |
users.manage | Access | Users, groups, roles, grants, tokens, SSO and LDAP settings. | no |
system.manage | System | Licence, nodes, queues, retention and maintenance. | no |
* | System | Every permission, unscoped. | no |
Built-in roles
Their permissions can be edited; the roles cannot be deleted or renamed.
| Role | Permissions |
|---|---|
| viewer | view |
| auditor | view, configs.content, inventory.export, audit.view |
| reviewer | view, configs.content, changes.review |
| operator | view, 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(defaultstructam-) 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
Originequal to the public URL's origin (or one listed inSTRUCTAM_ALLOWED_ORIGINS). - A request with
Authorizationis 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-Forentry that is not a trusted proxy when the peer is listed inSTRUCTAM_TRUSTED_PROXIES.
Questions the docs do not answer?
Ask the people who build Structam. Installation media and licences come from KazLabs.