Skip to content

feat(control): limit how long sign-ins last, and where they come from - #657

Merged
kalaspuff merged 11 commits into
mainfrom
fctl/1677-sign-in-with-the-organization-s-own-iden
Nov 28, 2026
Merged

kalaspuff merged 11 commits into
mainfrom
fctl/1677-sign-in-with-the-organization-s-own-iden

Conversation

@fctl-sh

@fctl-sh fctl-sh Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Instance admins now set session policies under Admin → Sign-in, or with fctl admin sign-in policies: how long a browser stays signed in after its sign-in and how long it may sit unused, how long a CLI stays signed in, the longest an access token may last, whether members make access tokens, and the networks (IP ranges) people sign in and send requests from. With Google required for a domain, this is what makes closing someone's Google account take them out of fctl: their browser and CLI sign in again through Google once the policy ends their sign-ins. Google sends apps no logout signal, so signals from providers are left to #652.

  • Every request checks its token against the policy, those made before it too, and saving one deletes what it ends at once. Admin → Sign-in and the CLI show what a change ends before it saves ("Saving signs out 14 browsers and 1 CLI at once, yours among them…"), and letting anything last longer, or come from more networks, takes confirming it's you where the instance asks for that.
  • Networks refuse browsers, CLIs, access tokens, admin tokens and service accounts from elsewhere. Runners, webhooks and published links aren't held to them. A browser outside the networks sees the sign-in page, which explains why, and keeps its sign-in for when it's back inside. An admin can't save ranges that leave out their own address.
  • Settings follows the policy: the access token dialog offers no expiry past the longest allowed, members see that only admins make tokens where that's the rule, and Devices says how long sign-ins last.
  • Docs: self-hosting.md (two new sections), organizations.md, security.md, api.md, cli.md, llms.txt, architecture.md, and ADR 0102.

I tested the domain rules in Rust, and a D1 test checks that the SQL saving ends exactly what each request refuses. The CLI and the web app have tests too, and cargo xtask check passes. Against cargo xtask serve, a script signed people in and drove the CLI and API. An access token backdated 40 days was refused, saying why. Members' tokens ended when only admins could make them. A 13-hour-old browser signed out under a 12-hour limit, and so did one unused for 2 hours under a 1-hour limit. An admin couldn't save networks that left out his own address. Outside the networks, the owner's access token was refused while her password sign-in went through, and a member's sign-in was refused.

This is the "Session policies" item of #618. What's left of #618 for Google, a workspace's own requirement, is in #659; once both merge, #618 can close. The parts that need other identity providers moved to new issues: #650 (Okta, Entra ID and other OpenID Connect providers, with their test sign-in and directory-managed names), #651 (SAML through a bridge), #652 (ending sign-ins on the provider's signal, Google's Cross-Account Protection included) and #653 (workspaces' own providers and verified domains on app.fctl.sh).

Refs #618

Screenshots

At c4fcb9f, against cargo xtask serve.

Admin → Sign-in → Staying signed in, as it is by default, then with a change waiting to be saved (light, dark, and dark at 390 px):

Staying signed in, light

A change and what saving it ends, light

A change and what saving it ends, dark

A change on a phone, dark

Admin → Sign-in → Networks, with ranges typed and the admin's own address beside them (light, dark):

Networks, light

Networks, dark

The sign-in page from outside the networks:

The sign-in page outside the networks

Settings → Security → Devices under a policy, the new access token dialog under a 90-day limit, and a member's access tokens where only admins make them:

Devices under a policy

The new access token dialog under a 90-day limit

A member's access tokens where only admins make them

Worth confirming

  • Decision: the policies apply to the tokens people already have, and saving one deletes those it ends, so relaxing it later brings none back. Members' access tokens that go when only admins may make them don't come back either.
  • Decision: admin tokens and service accounts' secrets aren't held to the lifetimes: they're machine credentials, and a directory sync that offboards people must not stop along with people's sign-ins. They are held to the networks.
  • Decision: the primary instance owner is held to the lifetimes, but signs in from anywhere with a browser or the CLI, as the instance's way in when its network's addresses change. Their access tokens and admin tokens are held to the networks.
  • Decision: "unused" means no request with the sign-in and no socket open with it, so a tab left open on a session, or on a page that updates itself, counts as use. The page says so. A browser's cookie lasts as long as its sign-in may (the policy's longest, and 30 days at most), and the server ends one unused too long.
  • Decision: a browser outside the networks counts as signed out but keeps its sign-in, so stepping off the VPN doesn't sign anyone out for good; CLIs and tokens are refused with a 403 that says why.
  • Decision: a browser is never kept signed in more than 30 days unused, the old fixed limit. The idle limit can be set from 5 minutes up to that.

fctl session


Warning

High risk. It changes how every browser, CLI and access token is accepted or refused on each request, saving a policy deletes the sign-ins it ends, and network limits can lock people out.

What it does. Lets instance admins set session policies: how long browsers and CLIs stay signed in, how long a browser may sit unused, the longest an access token may last, whether members make access tokens, and the networks people sign in from. Every request checks its token against the policy, saving a policy ends the sign-ins it rules out at once, and the admin page and CLI preview what a change will end. Open viewer sockets count as use, and a browser's cookie lasts as long as its sign-in may, with the server ending sign-ins unused too long.

Saving deletes sign-ins. Saving a stricter policy deletes the browsers, CLIs and member access tokens it ends, and relaxing it later doesn't bring them back.

fctl review's first look at 537a336 · 53 files, +3391 −75 · Review agent settings

fctl-sh Bot added 8 commits November 25, 2026 23:07
Instance admins set how long a browser stays signed in (from its sign-in,
and unused), how long a CLI stays signed in, the longest an access token
lasts and whether members make them. Every request checks its token
against them, and saving one ends at once what it doesn't let last.
`fctl admin sign-in policies` shows and changes them, with what a change
ends before it saves.
A draft of a change shows what saving it ends at once before its Save
button. Settings' access tokens last no longer than the instance lets
them, members see who makes them where only admins do, and Devices says
how long sign-ins last where the instance limits them.
…works

Instance admins name the IP ranges people sign in and send requests
from (InstanceSettings.networks): browsers, CLIs, access tokens, admin
tokens and service accounts elsewhere are refused, while runners,
webhooks and published links connect from anywhere. The primary
instance owner signs in from anywhere in a browser or the CLI, and an
admin can't save ranges their own address is outside of. Admin → Sign-in
has them beside the admin's address, `fctl admin sign-in policies
--networks` sets them, and the sign-in page says when a browser is
outside them.
The policy section ends with what it doesn't hold (admin tokens and
service accounts' secrets) instead of repeating its controls, a lone
member's token reads as one, its switch stays beside its label on a
phone, and Devices names browsers once.
@fctl-sh
fctl-sh Bot requested a review from kalaspuff as a code owner November 26, 2026 00:06
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/auth.rs Resolved
Comment thread web/src/components/sign-in/sessions.tsx Resolved
Comment thread crates/fctl-control/src/api/auth.rs Resolved
Comment thread crates/fctl-control/src/auth.rs Resolved
…tworks before writing

Access tokens store the end their makers chose, and every request
applies the policy's longest from when they were made, so relaxing the
policy gives that choice back. Open sockets count as use. Sign-up from
outside the networks is refused before the account and the invitation
are written, and a CLI's approved code waits for a poll from inside one
rather than being used up. The longest token life is named in days, and
Save waits for the preview of the draft as it is.
@fctl-sh

fctl-sh Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

On the summary's finding about sign-up from outside the networks: fixed in b9791d8. signup checks the network before it writes the account and marks the invitation used, as the Google sign-up path does. The setup path, at line 121, makes the primary instance owner, who signs in from anywhere, so it needs no check.

@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/auth.rs Resolved
An open socket's checks read its sign-in as in use without the end its
last recorded use gave it, and record that use as a request does, so
that its end slides and the hourly job doesn't delete it.
@fctl-review

This comment has been minimized.

Comment thread crates/fctl-control/src/auth.rs Resolved
…last

Its cookie lasts until the policy's longest from its sign-in, and 30
days at most, rather than its time unused, which only requests renew: a
tab that holds a socket open keeps its cookie, and the server still ends
a sign-in unused too long.
@kalaspuff
kalaspuff merged commit ed926ea into main Nov 28, 2026
13 of 15 checks passed
@kalaspuff
kalaspuff deleted the fctl/1677-sign-in-with-the-organization-s-own-iden branch November 28, 2026 09:55
fctl-sh Bot added a commit that referenced this pull request Nov 28, 2026
Main's session policies and networks (#657) and this branch's Slack
address matching both add instance settings, and both are kept. #657 took
ADR 0102, so this branch's Slack ADR becomes 0103, its links with it.
The generated TypeScript comes from the merged protocol.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant