- Python 92.7%
- HTML 6.3%
- Mako 1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| src | ||
| .gitignore | ||
| COPYING | ||
| COPYING.LESSER | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
splent_feature_confirmemail
The confirmemail feature of a SPLENT product line.
It proves that an address belongs to its account. With it installed, an
account opened by a sign-up waits until its owner follows the link mailed to
the address (auth's AUTH_REQUIRE_VERIFIED_EMAIL, empty by default, reads
its presence). It needs auth 1.23 or later, which owns the account and the
one-time tokens the links are made of, and mail, which sends them.
The link
- auth sends
user-registered. Unless the address is confirmed already (a provider vouched for it:email_verified=True), a link goes to it. The link carries one of auth's one-time tokens: 32 random bytes, of which auth keeps the SHA-256, the account, the address it went to and its expiry (CONFIRM_EMAIL_TOKEN_MAX_AGE, a day). GET /confirm_user/<token>shows a page with a button and confirms nothing, so a mail scanner that opens every link changes nothing.- The
POSTspends the token and, in the same transaction, marks the address confirmed and ends every session of the account. It signs nobody in, and an account an administrator switched off stays off.
| Case | Result |
|---|---|
| A link used, expired, of the old signed kind, or not a link at all | 410, a page that says which and asks for a new link |
| The same link pressed twice at once | One confirms, the other gets the 410 page |
| An address change whose address another account took meanwhile | 410, a page that says the account kept its address |
| The database refuses the confirmation | 503, the page again saying the link still works (errors.ConfirmationNotSaved); the driver's message goes to the log |
The token pages send no Referer, are not cached and run no script of
another site (auth's keep_token_private).
A new link
/confirmemail asks for an address and mails a new link when it belongs to
an account waiting for one. The answer is the same either way. Logging in
with the right password on an account that waits also mails a new link. An
account gets one link per CONFIRM_EMAIL_RESEND_SECONDS (five minutes)
however often it is asked for, and following any link spends the others.
Accounts carried over from an older site
An account auth knows was carried over from a site that never confirmed
addresses (legacy_v2, User.is_legacy_unconfirmed) signs in unconfirmed.
auth asks for its link at its first sign-in, through send_confirmation,
and again from its /account/confirm-email page when the person asks. Its
mail says it comes from the previous version of the site and what waits for
the confirmation, instead of the sign-up's wording. The button confirms it
as any other.
A new address
auth's My account asks for the current password to change the address and
keeps the new one in pending_email. auth calls
ConfirmemailService.send_email_change(user, old_email), which mails the new
address a link to /confirm_email_change/<token> and tells the old address
that someone asked to move the account. The account keeps signing in with
its address until the link is followed. The button then moves it, marks the
new address confirmed, ends every session, spends the links mailed to the
old address and tells it the change was made.
Settings
| Setting | Default | |
|---|---|---|
CONFIRM_EMAIL_TOKEN_MAX_AGE |
86400 | Seconds a link works |
CONFIRM_EMAIL_RESEND_SECONDS |
300 | Seconds between two links to one account |
CONFIRM_EMAIL_SALT is no longer read: the links are not signed values.
Use it in a product
splent feature:add splent_feature_confirmemail