About
Accounts, login, logout, sessions and one password policy for every form that sets a password
Provides
AuthTokenThrottleFailureUser
AuthenticationServiceOneTimeTokenService
/account/account/confirm-email/account/delete/account/export/account/reauthenticate/account/sign-out-everywhere/admin/users/admin/users/<int:user_id>/delete/admin/users/<int:user_id>/edit/admin/users/new/login/logout
admin.bar.contextlayout.anonymous_sidebarlayout.authenticated_sidebarlayout.footerlayout.nav.endlayout.navbar.anonymouslayout.navbar.authenticatedlayout.scripts
user-deletinguser-disableduser-enableduser-password-changeduser-registered
es
Commands
-
$
splent feature:auth create-user EMAIL [OPTIONS]Create a user who can sign in right away.
-
$
splent feature:auth list-usersList all users in the active product.
-
$
splent feature:auth purge-tokensRemove the expired one-time links (reset, confirmation).
-
$
splent feature:auth require-password-reset EMAIL [OPTIONS]Make ANY account choose a new password before it signs in, by email.
-
$
splent feature:auth set-password EMAIL [OPTIONS]Change ANY user's password, by email.
-
$
splent feature:auth set-role EMAIL ROLEChange ANY user's role, by email. ROLE is one of admin, staff, user.
-
$
splent feature:auth set-service-account EMAIL [OPTIONS]Mark ANY account as one a program signs in with, by email.
Run them in your workspace once the feature is installed in the selected product.
Configuration
| Setting | Default | What it does |
|---|---|---|
AUTH_NAV_LOGIN |
true
|
"Log in" in the public header. A site where staff reach the panel by typing the URL turns it off. |
AUTH_FOOTER_LOGIN |
false
|
A quiet login link in the footer, for sites without one in the nav. |
AUTH_LOGIN_LAYOUT |
empty | The shell the sign-in page renders in. Empty means the admin shell, which is what a product that is only a back office has. A product with a public shell names it, so its front door does not look like a different site. |
AUTH_MIGRATION_LEGACY_ROLE |
empty | Read once, by the migration that introduced roles, as the role every existing account is given when the column appears. Empty lets the migration decide only when there is nothing to decide (no accounts, or a single one, which stays admin). With several accounts it fails and says what to set. Declare it in the product's [tool.splent.config], "user" where people can sign up, "admin" to keep every existing account as an administrator, then bring it into the environment the migration reads. In development run splent product:env --merge --dev and then splent db:upgrade. In production splent product:build writes it to docker/.env.deploy.example, splent product:deploy brings it into docker/.env.deploy, and the container applies the migration when it starts. Changing it afterwards changes nothing, since that migration has already run. |
AUTH_MIGRATION_INACTIVE_ACCOUNTS |
empty | Read once, by the migration that split active into switched off and verified (auth0004_account_state), as what an inactive account was: "pending", waiting for its confirmation link, or "disabled", switched off by an administrator. Empty lets the migration decide, from whether the product confirms addresses. Brought into the environment the migration reads like AUTH_MIGRATION_LEGACY_ROLE above, and changing it afterwards changes nothing. |
AUTH_LANDING_ENDPOINT |
public.index
|
Where logging in and out sends a reader who asked for no page in particular. A product without the public feature (a storefront that owns "/") names its own home; an endpoint the product does not have sends the reader to "/". |
AUTH_LOGIN_MAX_ATTEMPTS |
10
|
The login throttle. Failures are counted in the product's database, so every worker and every container shares one count (see throttle.py). An account is counted however its address is spelled. Setting one of the three MAX budgets below to 0 turns that check off. Failed logins allowed from one address against one account in a window, checked before the password is. Per account as well as per address, so the hundreds of people behind a campus or office NAT never share a budget, and ten is more than anyone needs to remember their own password while holding a single guesser to forty attempts an hour against one account. |
AUTH_LOGIN_MAX_ACCOUNT_ATTEMPTS |
50
|
Failed logins allowed against one account from every address together, for a guesser who rotates addresses. Higher than the one above so a single guesser meets their own budget first. It never refuses the right password. |
AUTH_LOGIN_MAX_ADDRESS_ATTEMPTS |
200
|
Failed logins allowed from one address against every account together, for one address spraying a password or two across many accounts, which the two budgets above never see. Checked before the password and not cleared by a success. When spent it refuses everyone behind that address, so it sits far above a NAT's honest mistakes (a lab of a hundred people mistyping twice in the same quarter of an hour) while holding a sprayer to two hundred accounts per window. |
AUTH_LOGIN_WINDOW_SECONDS |
900
|
The window the three budgets are counted over, in seconds. |
AUTH_PASSWORD_MIN_LENGTH |
8
|
The password policy (passwords.py). The accounts screen, My account and the create-user and set-password commands apply it, and so does another feature's form (a sign-up, a reset link) that sets passwords through it. The shortest password accepted, from 8 to 128. A framework that reads the schema below refuses any other value at boot; an older one makes a lower value 8 and a higher one 128, with a warning in the log. No password longer than 128 characters can be set. It applies when a password is set, never at login, so an account whose password is shorter keeps signing in with it. |
AUTH_PASSWORD_CONFIRM |
false
|
Whether the forms that follow the policy ask for a new password twice. It adds the second box where such a form would ask once, and My account always asks twice. |
AUTH_PASSWORD_BREACH_CHECK |
false
|
Whether a password that appears in a known data breach is refused, asking Have I Been Pwned's range API with k-anonymity: only the first five characters of the password's SHA-1 leave the server. Off by default, since it calls a third party whenever a password is set. A service that does not answer in AUTH_PASSWORD_BREACH_TIMEOUT seconds lets the password through and logs a warning. AUTH_PASSWORD_BREACH_URL points it at another copy of the range API (a mirror inside the network). |
AUTH_PASSWORD_BREACH_URL |
https://api.pwnedpasswords.com/range/
|
No description yet. |
AUTH_PASSWORD_BREACH_TIMEOUT |
3
|
No description yet. |
AUTH_REAUTH_SECONDS |
900
|
Seconds a sign-in counts as recent. Linking a provider account, and setting a password on an account that never had one, ask for a sign-in this recent, and otherwise for the password (or a provider the account signs in with) again on /account/reauthenticate. |
AUTH_REMEMBER_DAYS |
30
|
Days a "Remember me" cookie keeps a browser signed in. 0 takes the box off the login form. Every session and cookie also ends with a new password, when the account is switched off and with "Sign out everywhere else". |
AUTH_LOGOUT_GET |
true
|
Whether a plain GET of /logout still signs out. On for one minor, for the links that are not forms yet (a shell's menu entry, another feature's link, a test that GETs /logout). Off, the GET shows a page with a button that signs out by POST, so a link or an image on another site cannot sign anyone out. auth 2.0 turns it off. |
AUTH_SELF_DELETION |
true
|
Whether a person may delete their own account from My account. The features that keep something of the account remove it, or keep it without the account, as it goes (the user-deleting signal). A product whose accounts an institution hands out and takes back turns it off, and an administrator deletes them from the accounts screen. |
These are the defaults. A product changes them in its own pyproject.toml, under [tool.splent.config], or in .env.deploy in production.
Dependencies
In product lines
- cms_spl In every product
- labcompute In every product
- marketplace_spl In every product
- openhubs_spl In every product
- openwiki_spl In every product
- sample_splent_spl In every product
Extension points
auth.login.error_hintauth.login.form_footerauth.login.providersauth.reauthenticate.methods
auth/admin/user_form.htmlauth/admin/users.htmlauth/confirm_email.htmlauth/delete_account.htmlauth/login_form.htmlauth/logout.htmlauth/my_account.htmlauth/reauthenticate.htmlhooks/anonymous_sidebar_items.htmlhooks/authenticated_sidebar_items.htmlhooks/footer_login.htmlhooks/my_account_sidebar_item.htmlhooks/navbar_anonymous.htmlhooks/navbar_authenticated.htmlhooks/public_nav.htmlhooks/users_sidebar_item.html
AuthenticationServiceOneTimeTokenService
AuthTokenThrottleFailureUser
Other features fill its hook slots. A refinement can override its templates and services or extend its models without forking it.
Compatibility
>=3.13
>=1.30.0
email_validatorpytz>=2024.1