# Session limits

> The idle time and the session maximum of eaxScada sessions - the security defaults, the values per group, how the value that applies is chosen (shortest wins, the station's idle cap), what counts as activity, the countdown, the return to viewing only, tabs that follow each other - and the session, activity, session-policy and station routes with their answers and audit records.

Product: eaxScada · Type: Reference · Editions: Starter, Pro, Enterprise
Source: https://eaxware.com/docs/eaxscada/reference/session-limits/
Status: migrated page, not yet verified against the current code.

Every session of a person has two limits:

- **Idle time**: the session ends after this long without input. It can be off.
- **Session maximum**: the session ends this long after sign-in, used or not. It cannot be extended. It is never more than 12 hours.

Both are enforced by the server, in every edition. The browser shows a countdown, but a session ends on the server whether the browser shows it or not.

## Settings

Set them in **Security > Groups**: **Edit defaults** for the security defaults, and each group's editor for the group's own values.

| Setting | Where | Values | Default |
|---|---|---|---|
| Default idle time | Session defaults | 0 (off) or 1 to 720 minutes | **30 minutes on a new installation; off on an upgraded one** until you set it |
| Default session maximum | Session defaults | 1 to 12 hours | 12 hours |
| Warning before an idle sign-out | Session defaults | 10 to 300 seconds | 60 seconds |
| Idle time | Each group | empty (not set) or 1 to 720 minutes | not set |
| Session maximum | Each group | empty (not set) or 1 to 12 hours | not set |
| Idle cap | Each view-only station | empty (no cap) or 1 to 720 minutes | no cap |
[Image: Security > Groups: the Session defaults band with Edit defaults, a note about kiosk screens that are not stations, and the groups grid with its Idle time and Session maximum columns.]
[Image: Security > Groups: the Session defaults band with Edit defaults, a note about kiosk screens that are not stations, and the groups grid with its Idle time and Session maximum columns.]

The session defaults apply to users whose groups set nothing.
A change is security configuration. It is recorded in the Access audit before it takes effect (`SESSION_POLICY_CHANGED` with the old and new values, for the defaults and for a group's limits); without the record nothing changes. It applies at once to open sessions: a shorter idle time is measured from the session's last input, so a session idle for longer than the new value ends at the next check.

## Which value applies: shortest wins

For each session the server takes:

1. **Idle time**: the shortest idle time set by any of the user's groups. When no group sets one, the default idle time.
2. Then, on a view-only station, the station's **idle cap** when it is shorter.
3. **Session maximum**: the shortest maximum set by any of the user's groups. When no group sets one, the default maximum. Never more than 12 hours.

A person in **Operators** (25 min) and **Engineering** (10 min) gets 10 minutes: they carry engineering rights in that session, so the stricter group holds.

The user editor in **Security > Users** shows the values that apply under **Session limits that apply**, and what sets each one ("set by group Engineering", "security default", "capped by station ...", "off").
[Image: The user editor for jdoe, member of the Engineering and Operators groups, with Session limits that apply: Idle time 10 min, set by group Engineering; Session maximum 8 h, set by group Engineering.]
[Image: The user editor for jdoe, member of the Engineering and Operators groups, with Session limits that apply: Idle time 10 min, set by group Engineering; Session maximum 8 h, set by group Engineering.]

Of several groups, the shortest value applies.
### Sessions idle time does not apply to

| Session | Idle time | Maximum |
|---|---|---|
| A person in the browser (password or SSO) | yes | yes |
| A NATS client signed in with a user name and password (it opens a person's session) | yes: broker traffic is not input, so the client is disconnected after the idle time | yes |
| A view-only station with nobody signed in | no | yes; the station starts a new viewing session by itself |
| The AI co-pilot account | no | yes |
| API tokens and PLC tokens | no: they are not sessions and keep their own expiry | no |

A program that stays connected to the broker should use an NKey device identity, not a user name and password.

## What counts as activity

| Counts | Does not count |
|---|---|
| Real input on operator screens and in the Studio: pointer down, key down, wheel, touch. The browser reports it at most every 20 seconds while input goes on. | Live values on `/ws`, subscriptions |
| An operator or engineering request the server accepts, such as a tag write, a saved change or a deploy | Reads and polling, alarm list refreshes, chart refreshes |
| **Stay signed in** in the countdown | Screen scripts and startup scripts, timers |
| | `GET /api/auth/session` |
| | Input that a script or a browser extension fakes: only input the browser marks as real counts |

A screen left alone with live values streaming is idle.

## The countdown

Before an idle end, the operator screens and the Studio show **Still there?** with the time left. On operator screens: "You will be signed out in 0:59 because this screen has not been used." In the Studio: "You will be signed out of Studio in 0:59 because it has not been used.", with "Unsaved changes in open editors will be lost: save them now, or choose Stay signed in." When the open screen has unsaved edits, it adds that they are kept as a draft in this browser. On a station the operator screen's text adds "and this screen returns to viewing only."

[Image: The Still there? dialog over a dimmed operator screen: "You will be signed out in 0:14 because this screen has not been used, and this screen returns to viewing only.", with Sign out now and Stay signed in.]
[Image: The Still there? dialog in the Studio: "You will be signed out of Studio in 0:14 because it has not been used.", the warning that unsaved changes in open editors will be lost, Sign out now and Stay signed in.]
[Image: The Still there? dialog in the Studio: "You will be signed out of Studio in 0:14 because it has not been used.", the warning that unsaved changes in open editors will be lost, Sign out now and Stay signed in.]

In the Studio the countdown warns about unsaved changes.
- It opens **Warning before an idle sign-out** seconds before the end, and never earlier than a quarter of the idle time before it (with 1 minute of idle time, 15 seconds).
- **Stay signed in**, a key or a click counts as activity and closes it. **Sign out now** ends the session.
- The time is counted from the server's clock, not the browser's.
- Five minutes before the session maximum, a notice says "Your session ends at 14:00. Sign in again to continue." The maximum cannot be extended.

## When a session ends

A session ends at its idle deadline, at its maximum, on sign-out, or when an administrator ends it (disabling, locking or deleting the account, or changing its roles or groups). Then:

- The server refuses the session's next request (`401`, `"status": "session_ended"`, `"reason": "idle"` or `"max"`). A sweep every 5 seconds ends sessions past a deadline even when no request comes.
- Its live-value socket closes within 3 seconds, and its NATS connections are closed (`NATS_CONNECTION_CLOSED`, with the reason and the client address).
- The signature tickets issued in it are void: a signature started 10 seconds before the end cannot be completed after it.
- In the browser, every open command dialog, confirmation and keypad closes **without sending**. A command sent before the end completes and is recorded under its user. Nothing is sent again.
- **On a view-only station**, the screen returns to viewing only, on the same screen when the station may show it. It says why, for example "Signed out after a time without use: this screen is for viewing only again."
- **Elsewhere**, the browser shows the sign-in page.
- **The Studio** always goes to the sign-in page, on a station too. Before it goes, the unsaved edits of the open screen are kept as a draft in this browser, and the screen designer offers them again when you open that screen. Unsaved changes in other editors are lost.

**When the user changes on a runtime screen** (an in-place sign-in, a sign-out, or a return to viewing only on a station), the screen follows the new user at once (since eaxScada `392d7a2a`):

- The live-value connection opens again straight away, in about 0.1 to 0.2 seconds, with the new user's rights.
- Until the new user is read, every element that depends on a role stays hidden or disabled. An unknown user is denied, never treated as the previous one.
- The values on the screen show as stale until the new values arrive.

A change of a topic rule, a role, a group or a group's roles does not end a session. It closes only the NATS connections of the users whose broker rights change, and those clients connect again with their current rights. See [Broker connections](/docs/platform/explanation/security-and-part-11/#47-broker-connections).

### Tabs follow each other

All tabs of one browser share the session, held in the HttpOnly `scada_session` cookie only (no token in Web Storage; see [Where the browser keeps the session](/docs/platform/explanation/security-and-part-11/#71b-where-the-browser-keeps-the-session)). Input in one tab counts for all of them. Signing in or signing out in one tab happens in every tab, and every tab of a station returns to viewing only together.

## Routes

`GET /api/auth/session` and `POST /api/auth/activity` may be used by eaxCloud remote sessions (view class). The session policy and the station routes are never reached through remote access. Every route that changes something needs `Content-Type: application/json` and a same-origin request; a cross-site request is refused with `403`.

### `GET /api/auth/session`

The caller's session deadlines. Not activity.

```json
{
  "idle_deadline": 1795406400000,
  "hard_deadline": 1795442400000,
  "server_now": 1795404600000,
  "view_only": false,
  "station": null,
  "idle_timeout_seconds": 1800,
  "idle_warning_seconds": 45,
  "idle_source": "group:grp_1795390172941905200",
  "max_source": "default"
}
```

Times are Unix milliseconds. `idle_deadline` is `null` and `idle_timeout_seconds` is `0` when idle time does not apply. `view_only` is `true` for a station with nobody signed in. Without a session: `401 {"error": "not authenticated", "status": "session_ended"}`, with `"reason": "idle"` or `"max"` when it just ended.

The answer of `POST /api/auth/login` carries the same `session` object, and `idle_deadline` and `hard_deadline` at its top level.

### `POST /api/auth/activity`

Body `{}`. Reports real input. Answers the session as `GET /api/auth/session` does, after the touch, or `401 session_ended`.

### `GET` and `PUT /api/auth/session-policy`

The security defaults (Administrator).

- `GET` answers `{policy, bounds}`; with `?user=<id>` (and optionally `&station=<id>`) also `effective`: the values that apply to that user, with `idle_source` and `max_source` (`group:<id>`, `station:<id>`, `default`) and `idle_exempt` (`viewer`, `ai_copilot`).
- `PUT` takes any of `default_idle_minutes` (0 = off), `default_max_session_hours` and `idle_warning_seconds`. A value outside its bounds is refused with `400`.

The group routes take `idle_minutes` and `max_session_hours` (0 = not set).

### Station routes

| Route | Who | Does |
|---|---|---|
| `GET /api/auth/station` | anyone, a station included | This browser's station: `{station, view_only}`; `station` is `null` when the browser is not a paired station. |
| `POST /api/auth/station/pair` | public | `{"code": "XXXX-XXXX"}` pairs this browser and sets its station cookie. |
| `GET /api/security/stations` | Administrator | The stations, with `viewer_name`, `paired`, `pairing_expires_at`, `last_seen_at` and `last_seen_ip`. |
| `POST /api/security/stations` | Administrator | Creates a station; answers `201` with `station` and `pairing` (`code`, `expires_at`). |
| `PUT /api/security/stations/{id}` | Administrator | Changes it; `"enabled": false` disables it. |
| `DELETE /api/security/stations/{id}` | Administrator | Deletes it. |
| `POST /api/security/stations/{id}/pairing-code` | Administrator | A new pairing code: `{code, expires_at}`. |
| `POST /api/security/stations/{id}/pair-here` | Administrator | Pairs the administrator's own browser. |
| `POST /api/security/stations/viewers` | Administrator | `{"name": "lobby"}` creates a viewer identity without a station: no password, no role, never signs in. Answers `201` with `viewer`, `"created": true` and `rebound` (the ids of the stations bound to it on this node), or `200` with `"created": false` when it exists already. The Studio's **Create viewer identity** action in **Security > Stations** calls it. |

A station body has `name`, `screens` (the start screen leads the list), `allowed_cidrs`, `idle_minutes`, `allow_studio`, `show_alarms`, `enabled`, and, when it is created, either `viewer_user_id` (an existing viewer identity) or `viewer_name` (a new one; default `viewer`). A member left out keeps its value. An unknown member is refused.

| Answer | Code | Why |
|---|---|---|
| `400` | `pairing_failed` | The code is wrong or has expired. |
| `400` | `invalid`, `bad_request` | A value outside its bounds, an unknown member, or `viewer_user_id` that is not a viewer identity. |
| `403` | `cross_site_refused` | The request came from another site. |
| `403` | `remote_refused` | The request came through eaxCloud remote access. |
| `403` | `viewer_refused` | A station with nobody signed in asked for it. |
| `404` | `not_found` | No such station. |
| `409` | `station_disabled` | A disabled station cannot be paired. |
| `409` | `viewer_unusable` | The station's viewer identity is missing or disabled. On an HA cluster also: a change, a new pairing code or a pair-here on a node where the station has no usable viewer identity (`create the viewer identity <name> on this node, or make the change on a node where the station works`); nothing changed on any node. For `POST /api/security/stations/viewers`: a person's account has that name. See the `viewer_name` member below. |
| `429` | `pairing_rate_limited` | 5 pairing attempts from this address in 10 minutes, or 50 wrong codes from all addresses. |
| `503` | `AUDIT_NOT_WRITTEN` | The record could not be written: nothing changed. |
| `503` | `stations_unavailable`, `store_unavailable` | The station store is not open, or could not save. On an HA cluster also: the cluster did not confirm the change, or this node is not yet synchronized with the cluster or has lost its change feed. Nothing changed. |

A refusal body is `{"error": "<message>", "code": "<code>"}`. A `409 viewer_unusable` on an HA cluster also carries `viewer_name` when the server knows the name: the viewer identity to create on this node, for example `{"error": "the station's viewer identity is not usable on this node: create the viewer identity control_room on this node, or make the change on a node where the station works", "code": "viewer_unusable", "viewer_name": "control_room"}` (since eaxScada `744c4d7f`). It comes with a station change, a new pairing code, a pair-here and a screen pairing with a code. There is no `viewer_name` when the account of that name is a person, when a single server has the viewer identity missing or disabled, or when the name is not known: creating a viewer identity would not help there. The messages and the status codes are unchanged.

Requests a station may not make: `403 viewer_refused` on a route it may not read, `401` for any request other than a read ("sign in to operate"), `403 viewer_alarms_hidden` for alarms when **Show alarms** is off, `403` for a screen outside its list. A person signed in on a station that does not allow the Studio gets `403 studio_not_on_station` on the Studio.

On an HA cluster the stations are replicated between the nodes. Pairing codes, `last_seen_at` and `last_seen_ip` are each node's own, and a code is redeemed only on the node that issued it. Until a node holds the cluster's stations, it uses no station credential. See [On an HA cluster](/docs/eaxscada/how-to/set-up-a-view-only-station/#7-on-an-ha-cluster).

A viewer identity's read rights are permission rules (`POST /api/auth/permissions`, or the Studio's **Read rights for** button on the station's row). A rule for a viewer identity can only allow `subscribe` or `read`; any other rule is refused with `400`, code `viewer_identity`, and recorded as `PERMISSION_CHANGE_REFUSED`.

## Audit records

In the Access audit, every edition:

| Event | When |
|---|---|
| `SESSION_POLICY_CHANGED` | The security defaults or a group's session limits change (recorded before the change). |
| `SESSION_IDLE_END`, `SESSION_MAX_END` | A session ends at its idle deadline or its maximum. |
| `NATS_CONNECTION_CLOSED` | A user's open NATS connection is closed: its session ended, its account is no longer allowed, or its broker rights changed or could not be read. With the reason and the client address. |
| `STATION_CREATED`, `STATION_CHANGED`, `STATION_DISABLED`, `STATION_DELETED`, `STATION_PAIRING_CODE`, `STATION_PAIRED` | Station administration and pairing (recorded before the change). |
| `VIEWER_CREATED` | A viewer identity is created, with a station or by `POST /api/security/stations/viewers` (recorded before it is created). |
| `PAIRING_FAILED` | A wrong or expired pairing code (at most once a minute per address). |
| `VIEWONLY_START` | A station starts viewing (after its start, a pairing or a return; not again for a reload). |
| `VIEWONLY_SIGNIN` | A person signs in on a station. |
| `VIEWONLY_RETURN` | A station returns to viewing only, with the reason (sign-out, idle, maximum, revoked, station disabled, paired again). |
| `VIEWONLY_REFUSED` | A station asked for something it may not do (at most once a minute per station, method and route). |
| `STATION_REPLICATED` | HA cluster: this node applied a station change made on another node, or synchronized its stations with the cluster's, with what changed and the node it came from. |
| `ACCOUNT_LOCKED_ADDRESS` | An account is locked from one address. On an HA cluster the counts are shared by the nodes, and the lock applies from that address on every node. See [the lockout](/docs/platform/explanation/security-and-part-11/#42-lockout-parameters). |
| `LOCKOUT_SHARED_UNAVAILABLE` | HA cluster: the shared lockout store does not answer, so this node uses its own lockout checks until it does (at most once a minute). Also recorded when an unlock could not reach the store: that unlock applies on this node only. |
| `LOCKOUT_SHARED_RESTORED` | HA cluster: the shared lockout store answers again, and this node merged its counts and locks into it (at most once a minute). |
| `CROSS_ORIGIN_REFUSED` | A request that changes something, sent with a session or station cookie from a page of another origin, or a sign-in from another origin, was refused (`403 cross_origin`; at most once a minute per address). See [the origin check](/docs/platform/explanation/security-and-part-11/#71a-cookie-authenticated-requests-from-another-origin). |

## Related

- [Set up a view-only station](/docs/eaxscada/how-to/set-up-a-view-only-station/).
- [Security and 21 CFR Part 11](/docs/platform/explanation/security-and-part-11/#46-idle-time-and-session-maximum): idle time and IEC 62443, Part 11.
- [Sign-in and profile API](/docs/eaxscada/reference/sign-in-and-profile-api/).
