Skip to main content

Module auth

Module auth 

Source
Expand description

Who the user is (M3.5; see archive/PROJECT.md, Authentication: as little as possible in schedr). The name is recorded on commands, never used to allow or deny anything; there are no roles.

  • A caller proven to be schedr ui passes the person’s name on in USER_HEADER (decision 36): proven by its mTLS certificate on the webserver’s UI port (that listener marks its requests ProvenUi), by the token it presents in UI_TOKEN_HEADER where there is no mTLS (a mesh, a standalone), or by calling in-process (standalone’s own UI). Only so proven is the name taken; anyone else’s USER_HEADER is ignored.
  • Anyone else, by the mode: none takes the identity header’s value if there is one (else anonymous); proxy_header requires the SSO proxy’s header; basic checks HTTP Basic credentials against bcrypt hashes. A request refused is 401 (with a Basic challenge in basic mode).

The same rules serve the UI’s own pages ([ui.auth]), with no UI in front of it.

Structs§

Auth
How a role tells who the user is.
AuthTimings
How the users and the UI’s token are followed.
Followed
A value read from a file, and read again when the file changes: the file is looked at at most every RECHECK (its modification time and length), and read again when they changed. A file that can’t be read or doesn’t parse leaves the value as it was (logged as an error: a mistake in the deployment), and is tried again at the next look. Or a fixed value.
ProvenUi
A request from schedr ui, proven by how it arrived (the UI port’s mTLS, or in-process): a request extension, which no client can set.
User
Who a request is from (a request extension, set by Auth::user’s middleware).
Users
Users of basic mode: names and their bcrypt hashes.

Enums§

Refused
Why a request is refused.

Constants§

ANONYMOUS
The name recorded when no one is named.
DEFAULT_PROXY_HEADER
The header an SSO proxy names the user in, when identity_header isn’t set.
MAX_NAME
The longest name taken (a longer one is refused, not cut).
MIN_UI_TOKEN
The shortest token taken.
RECHECK
How often a followed file is looked at for a change, at most.
REMEMBERED
How long a check that passed is remembered.
UI_TOKEN_HEADER
The header schedr ui presents its token in, where there is no mTLS.
USER_HEADER
The header schedr ui names the person in (taken only from a proven UI).

Functions§

basic_credentials
The user name and password of an Authorization: Basic header.
browser_same_origin
Whether a browser says a request comes from the page’s own origin: Sec-Fetch-Site (same-origin, or none: typed by the user), else an Origin whose host is the request’s (X-Forwarded-Host behind a proxy; default ports aside). None when neither header is there: not a browser’s request (a CLI, schedr ui), or an old browser’s GET.
is_open
Whether a request for path is open to anyone: the API’s description and Swagger UI (they show what the API is, nothing of its data; decision 2.11a).
read_ui_token
The UI’s token in the file at path, followed (its text, trimmed).
refuse_cross_site
The webserver’s middleware refusing (403) a write a browser sends from another site: a browser attaches Basic credentials it remembers, or a proxy’s cookie, to any site’s form, so a page elsewhere could act as the person signed in. Requests no browser header marks (the CLI, schedr ui) pass.
require
The webserver’s middleware: the request’s User set, or a 401.

Type Aliases§

UiToken
The token a UI presents ([webserver] ui_token_file, [[ui.deployments]] token_file), followed: a new token takes effect without a restart.