// PART 09
RBAC and secrets
Authorization has two layers: a role resolver that decides what a user is, and a secrets layout that decides what credentials exist and where. Both are small, explicit, and easy to verify in code.
Roles
resolve_user_role (botserver/src/security/user_role.rs) resolves a user’s
role from the database — including group membership (rbac_user_groups), with
a group name containing “admin” granting the admin role, and the user record
existing as a foreign-key-real row. Variants take an optional email for
scoped checks.
| Role | Practical effect |
|---|---|
| admin | sees admin_only catalog commands, admin routes, settings surfaces |
| standard user | the filtered manifest; own files, own sessions |
| guest | the WS fallback identity (guest_<id>@anonymous.local); per-user lookups scope to the guest |
The same resolver feeds the API command catalog: entries marked
admin_only: true are filtered from the injected manifest for non-admin
users, and the executor enforces the same rule server-side. Authorization is
never prompt text.
BASIC scripts see the resolved role as the ROLE scope variable, which is how
a start.bas gates admin-only suggestions or tools:
IF role = "admin" THEN
ADD SUGGESTION "Open admin console"
END IF
Groups
Groups mirror organizational structure and are the unit of membership:
directory-backed groups (Zitadel) flow into the role resolver through
botcoredirectory (groups/, group_authz.rs). A user in no group is a
standard user; group membership is additive, not hierarchical.
Secrets
The layout is one Vault hierarchy with per-service and per-bot paths:
| Path | Contents |
|---|---|
secret/gbo/drive |
object storage credentials (accesskey, secret, bucket, optional endpoint, region, fallback_endpoint, backend) |
secret/gbo/tables, secret/gbo/cache, secret/gbo/directory |
PostgreSQL, Valkey, Zitadel |
secret/gbo/llm |
global LLM fallback (url, model, openai_key) |
secret/gbo/{org}/{branch}/{bot} |
per-bot LLM settings (llm-url, llm-model, llm-key, llm-provider, system-prompt, history-limit) and channel secrets |
secret/gbo/system/security |
CSRF signing secret and related node secrets |
secret/gbo/vectordb, secret/gbo/meet, secret/gbo/email, secret/gbo/alm, secret/gbo/encryption |
component credentials |
Rules the code enforces:
- Vault first.
ConfigManager::get_configreads the per-bot path, then nil-path/global, then environment variables as fallback (botcore/src/config/from_vault.rs). - No secrets in
config.csv. The Drive monitor drops sensitive keys from it; the file holds non-sensitive settings only. - Fail closed. The Teams adapter refuses to send when its credential is missing; the webhook signature gate rejects unsigned deliveries; production without a CSRF secret refuses to start.
- No plaintext sprawl. Only a narrow set of fields is encrypted at rest
via
encrypt_field; everything else relies on database and volume security, and the docs say so rather than overclaiming.
Operational checks
| Question | How to verify |
|---|---|
| What role does user X have? | resolve_user_role — check rbac_user_groups and the users row |
| Why is a command missing from the manifest? | it is admin_only and the user is not admin |
| Where does credential Y come from? | Vault path table above; from_vault.rs shows the resolution order |
| Is a token still valid after restart? | JWTs survive (persisted SaaS secret); session tokens depend on their store |