---
description: "FbExpert security: users, groups, ACL profiles, OTP, audit and alerts."
---

# Security and access

FbExpert security combines several layers: users, groups, access profiles, per-endpoint rules, OTP, audit and alerts.

## First administrator

The `/setup` page creates the first **super administrator** (`ADMIN`). It can be reached from any workstation over HTTPS as long as no user exists. Once the account is created, the page closes and redirects to `/login`.

Create it immediately after installation: while `/setup` is open, anyone who reaches the URL can create the first account.

<figure>
  <img src="/images/security/01-vue-ensemble.png" alt="Overview of FbExpert security" />
  <figcaption>Overview: users, groups, profiles, endpoints, databases and audit.</figcaption>
</figure>

## Users

A user has:

- a login name;
- a role, `ADMIN` or `USER`;
- an active/inactive status;
- an interface language;
- optionally an e-mail address and OTP;
- inactivity and session-duration limits.

<figure>
  <img src="/images/security/02-endpoints.png" alt="Per-endpoint access rules" />
  <figcaption>Per-endpoint access rules: IP, port and OTP exemption.</figcaption>
</figure>

## Groups

Groups simplify permission assignment. A user can belong to several groups.

<figure>
  <img src="/images/security/03-groupes.png" alt="Group management" />
  <figcaption>Groups, members and access rules.</figcaption>
</figure>

## Access profiles

A profile describes what a user or a group can do on a database:

- structure;
- read;
- write;
- schema development;
- operations;
- user and access management.

<figure>
  <img src="/images/security/04-acces-par-base.png" alt="Per-database access" />
  <figcaption>Assigning profiles per database and checking effective permissions.</figcaption>
</figure>

## Effective permissions

The `Effective permissions` screen shows the final result:

- legacy permissions;
- group permissions;
- profiles;
- exclusions.

::: tip Best practice
Always check effective permissions after an assignment. A permission granted by a group can complement an individual permission.
:::

## OTP

OTP can be enabled per user. The code is sent by e-mail and verified at login.

<figure>
  <img src="/images/security/11-otp-configuration.png" alt="OTP configuration" />
  <figcaption>OTP and recovery code configuration.</figcaption>
</figure>

<figure>
  <img src="/images/security/12-verification.png" alt="OTP verification" />
  <figcaption>OTP code verification screen.</figcaption>
</figure>

## Audit and alerts

The audit trail keeps logins, denials, sensitive operations and security changes. Alerts flag the events that need attention.

<figure>
  <img src="/images/security/10-audit.png" alt="Audit log" />
  <figcaption>Audit log, filterable by user, address, port and result.</figcaption>
</figure>

<figure>
  <img src="/images/security/13-alertes.png" alt="Security alerts" />
  <figcaption>Security alerts with acknowledgement.</figcaption>
</figure>

## Access denied

Unauthorized access is explicitly refused:

<figure>
  <img src="/images/security/06-endpoint-refuse.png" alt="Endpoint denied" />
  <figcaption>Denial of an unauthorized endpoint.</figcaption>
</figure>

<figure>
  <img src="/images/security/07-base-refusee.png" alt="Database denied" />
  <figcaption>Refusal to open an unauthorized database.</figcaption>
</figure>

## Login attempt limiting

Failed logins are counted per account and per IP. For a demo with a shared account, disable account lockout so that one visitor does not lock the demo for everyone:

```json
"Security": {
  "LoginMaxAttempts": 3,
  "LoginWindowMinutes": 10,
  "LoginLockoutMinutes": 60,
  "LoginLockUserAccount": false
}
```

Only the offending IPs are then blocked. Also add an nginx rate limit on `/auth/login` and, where possible, `fail2ban` on the host.

## HTTPS, Secure cookie and proxy

- The `FbExpert.Auth` cookie is marked **Secure**: a page served over HTTP never keeps the session.
- Since 7.457, a correct password submitted over HTTP shows an explicit message (`/login?error=tls`) instead of looping back to `/login`, and the failure is audited.
- Behind a remote proxy, declare its address: `ForwardedHeaders:TrustedProxies` (`["10.0.0.5"]` or `["10.0.1.0/24"]`) or `--trusted-proxy 10.0.0.5` at installation time. Otherwise the HTTPS scheme and the real client IP are ignored.
- For a lab deliberately running over HTTP: `Security:CookieSecurePolicy` = `SameAsRequest`. The Linux installer applies this value automatically when no local TLS is served (direct LAN access); the cookie remains `Secure` on HTTPS requests.
- Offline diagnostic: `FbExpert.Blazor --check-password <user>` (hash, database used, latest audit entries).
- Anti-forgery keys and cookies: stored in `DataDirectory/keys/data-protection`, they follow the data and survive restarts and `HOME` changes.

## Demonstration mode

In demonstration mode, non-administrator users are limited to read access:

- structure;
- `SELECT`;
- `EXECUTE`;
- DDL export.

Writes are hidden and uploads are refused.

### Public credentials

On a demo VM, the login page can display the public account and password, and prefill the form:

```json
"Demo": {
  "Enabled": true,
  "AllowAdminWrites": false,
  "ShowCredentials": true,
  "PublicUser": "demo",
  "PublicPassword": "mot-de-passe-public"
}
```

The values stay in the demo VM's `appsettings.json`, never in the repository. In production, `ShowCredentials` must remain `false`.

::: warning
Demonstration mode does not replace Firebird permissions. For a public instance, also apply a lock on the database side.
:::
