Skip to content
Get started
Bastionary › Knowledge base › Authorization

Idle, absolute, and renewal: session timeout policy that fits your risk

By Bastionary · Authorization

Most teams set a session timeout by copying whatever the framework shipped with, usually a flat expiry measured in hours, and move on. The problem is that a single number cannot express what you actually want. Idle timeout, absolute timeout, and sliding renewal each defend against a different attacker, and collapsing them into one value means you are over-protecting some users while leaving a gap for others.

Treating session lifetime as one knob is like having one lock for your front door, your safe, and your mailbox. The three timeouts are three different locks for three different threats, and a policy that fits your risk sets each one on purpose.

Three timeouts, three threats

Idle timeout: the unattended session

Idle timeout ends a session after a period of inactivity. The threat it addresses is physical: a user walks away from a logged-in terminal, a shared kiosk, a laptop left open in a coffee shop. The clock resets on every meaningful action, so an active user is never interrupted, while an abandoned session closes itself before someone else sits down.

Absolute timeout: the stolen long-lived token

Absolute timeout ends a session a fixed time after it began, no matter how active the user is. Its threat is a token that has been exfiltrated and is being actively used; idle timeout never fires for an attacker who keeps the session warm. The absolute cap guarantees that every session dies eventually and must re-authenticate, which bounds how long any single theft can pay off.

Sliding renewal: the usability release valve

Sliding renewal is what keeps active users from being logged out mid-task. Within the absolute ceiling, each valid refresh issues a new short access token, so a user working all day is not kicked out every fifteen minutes. It is not a security control on its own; it is the mechanism that lets you keep access tokens short without punishing real users.

The relationship that matters: idle timeout < absolute timeout, and access-token lifetime < idle timeout. Sliding renewal operates inside the idle window, and the idle window operates inside the absolute ceiling. If any of those orderings is inverted, one control silently cancels another.

Encoding all three in tokens

You can express the full policy with three timestamps carried in or alongside the session. The access token's own exp handles the short renewal cycle; the session record tracks idle and absolute limits.

{
  "sid": "b2f1c7e0-9a3d-4e21-8f0a-6c5d4b3a2e10",
  "sub": "user_8842",
  "iat": 1747000000,
  "exp": 1747000900,          // access token: +15 min (renewal cycle)
  "session": {
    "established_at": 1746990000,   // absolute clock starts here
    "last_activity": 1746999700,   // idle clock, bumped on activity
    "absolute_deadline": 1747076400, // established_at + 24h, immovable
    "idle_limit_seconds": 1800        // 30 min of inactivity ends it
  }
}

On each refresh, the server enforces all three rules before issuing a new access token. The logic is small but the ordering is load-bearing.

function evaluateSession(s: SessionState, now: number): "ok" | "expired" {
  if (now >= s.absoluteDeadline) return "expired";          // hard ceiling
  if (now - s.lastActivity >= s.idleLimitSeconds) return "expired"; // idle
  return "ok";
}

function onRefresh(s: SessionState, now: number) {
  if (evaluateSession(s, now) === "expired") throw new SessionExpired();
  s.lastActivity = now;              // sliding: reset idle clock
  // absoluteDeadline is NEVER moved
  return issueAccessToken(s, now, now + 15 * 60);
}

Gotcha: the most common bug is letting sliding renewal reset the absolute deadline. If each refresh pushes the absolute clock forward, an active (or actively-abused) session can live forever, and your absolute timeout defends against nothing. The absolute deadline is set once at login and never moves.

Setting the numbers to your risk, not a default

There is no universally right value, only a right value for a given sensitivity. Work from what the session can do:

  • Low risk (content, read-mostly consumer apps): idle 7 days, absolute 30 days, generous renewal. Optimize for never logging people out.
  • Medium risk (standard SaaS, business data): idle 30 minutes to 8 hours, absolute 24 hours, access tokens 15 minutes.
  • High risk (financial, admin consoles, health data): idle 5 to 15 minutes, absolute 1 to 8 hours, step-up re-auth for sensitive actions regardless of session age.

Regulatory regimes sometimes dictate these numbers, and where they do, the mandate wins. Where they do not, resist the urge to pick round numbers that feel safe; pick numbers that reflect what an attacker gains from a live session versus what a short timeout costs your real users.

Timeouts are not a substitute for revocation

Timeouts bound the maximum damage window passively, but they are slow. If you detect a compromise, you should not wait for the absolute clock to run out. Pair the timeout policy with active revocation, so a security event ends sessions immediately rather than whenever they happen to age out. The two are complementary: revocation handles the known-bad case, timeouts handle the silent case you never detect.

Make re-authentication humane

A strict policy only sticks if re-authentication is painless. When an idle timeout fires, preserve the user's in-progress work and context so that signing back in drops them exactly where they were, not at an empty dashboard. With passkeys, re-auth is a single biometric tap, which is what makes aggressive idle timeouts tolerable; a 15-minute idle limit is brutal behind a password and barely noticeable behind a passkey.

One policy per risk tier, owned by you

The teams that get session lifetime right stop looking for the single correct timeout and start defining a small set of named policies, each tuned to a risk tier, and assign applications to them. That requires an identity layer that treats idle, absolute, and renewal as independent, configurable controls rather than one opaque "session duration" field. When you own that layer, you set all three deliberately, per tier, to match your threat model instead of inheriting a default that was never about your risk.

Run it yourself

Bastionary is free, open-source software. Follow the quick start to have it running on your own server, or browse the releases on Git.

Get started