Commit graph

114 commits

Author SHA1 Message Date
4f00971f84 Use {% load static %} in templates
{% load staticfiles %} is deprecated in Django 2.2 and removed in 3.0.
2026-11-06 15:06:00 +03:00
15af9f8d9c Stop writing passwords and reset links to logs
SeedRetrieveCreate printed every submitted password to stdout, so it
ended up in container and server logs. The reset view logged complete
reset URLs at debug level, and those work as credentials until used.
2026-11-06 15:04:23 +03:00
0cb0344ac8 Compute the next uidNumber from LDAP instead of a local file
The highest uidNumber was cached in dal/ldap_max_uid_file. That breaks
with more than one replica and is lost on every container restart. The
uniqueness check behind it searched base '' (the root DSE), which
OpenLDAP never matches, so nothing caught a stale file. The error path
also referenced a setting that does not exist.

Now a paged search over ENTIRE_SEARCH_BASE finds the highest uidNumber
on each activation. Numbering is unchanged: the next number is above
both LDAP_DEFAULT_START_UID and every existing uidNumber.
LDAP_MAX_UID_FILE_PATH is no longer used.
2026-11-06 15:03:57 +03:00
f675ce9e31 Reject usernames that exist anywhere in the directory
Registration only collided inside ou=customers, so a staff username
from ou=users could be registered again as a customer, creating two
accounts with the same uid. Check the whole tree (ENTIRE_SEARCH_BASE)
on the register form, in the create API, and again at activation in
case the name was taken in between.
2026-11-06 15:03:14 +03:00
dad66040ed Keep passwords out of activation links
The activation link carried base64-encoded username, password, names
and email, so plaintext passwords ended up in mail archives, browser
history and proxy logs.

Registration now hashes the password to {SSHA} immediately and stores
it in a new PendingRegistration table (migration 0002). The emailed
link is /activate/<token>/ with a random token only, and activation
writes the stored hash into LDAP. Pending entries expire after 24h,
like reset tokens. This also drops the PseudoUser/token-generator
workaround.

Links in emails sent before deployment stop working; those users must
register again.
2026-11-06 15:02:41 +03:00
23ddf33d41 Require a verified reset link to set a new password
ResetRequest.post took the username from a hidden form field and
changed that user's password without checking any token, so anyone
could take over any account with a single POST to /reset/.

Opening a valid reset link now stores the verified username in the
session (valid for one hour, cleared after use). The POST only acts on
that user and ignores the form field. Reset tokens now come from
secrets.token_urlsafe, and malformed links return 404 instead of 500.
2026-11-06 15:01:47 +03:00
b44e2ffcf4 Escape user input in LDAP filters and DNs
The uid was formatted straight into search filters, so a password
reset for user '*' matched and changed the first entry in the tree
(staff accounts included). Escape filter values with
escape_filter_chars and DN values with escape_rdn.

Also fix the username pattern: [a-z|0-9|\-|_] allowed '|'.
2026-11-06 15:01:06 +03:00
13b1d9c23a Add end-to-end tests and pin production baseline dependencies
Restore root requirements.txt pinned to what production runs
(Django 2.2, last patch 2.2.28) so the upgrade starts from a
reproducible baseline. Restore logs/.keep; the logging config fails
on a fresh clone without the directory.

The tests drive every view over HTTP against the real test LDAP:
login, registration and activation, data and password changes,
password reset, account deletion, the create API and OTP seeds.
Known bugs are recorded as expected failures:
- password reset POST changes any user's password without a token
- LDAP filter injection in reset (user='*' hits the first entry)
- activation link carries the base64-encoded password
- a username from ou=users can be registered again under ou=customers
2026-11-06 14:46:24 +03:00
Nico Schottelius
e88cd4bc59 Register add 2021-12-12 20:39:32 +01:00
Timothee Floure
a7b9d70b9d Merge upstream repository and code running on production... 2020-05-24 08:04:25 +02:00
26916f7def Validate username format in what seem to be WIP API? 2020-05-01 11:11:24 +02:00
4cf0161d7c Ask for username instead of email for login, validate username on
registration
2020-05-01 11:08:13 +02:00
7cbdf62b96 Populate README, refresh configuration template 2020-05-01 11:07:29 +02:00
8a8cc5d20e better response messsage 2019-05-30 05:17:20 -04:00
e1b4aac222 fix typho response -> Response 2019-05-30 05:07:06 -04:00
f6b723b76a fix typho in creation link 2019-05-30 05:04:11 -04:00
ce5f88b134 fix hardwritten test 2019-05-26 16:59:52 -04:00
36d10deaab Added buttons for back to index and show seeds 2019-05-26 16:50:56 -04:00
d37144c541 seed listing view and template 2019-05-26 16:15:07 -04:00
321d8548da url for seed list 2019-05-26 16:13:58 -04:00
9576ae9064 Same messages in creation/deletion preventing scape chars errors in password 2019-05-06 11:42:58 -04:00
9711dc1ecc fix show message error when not valid credentials 2019-05-05 18:12:43 -04:00
54aa8f474e added rest framework conf 2019-05-05 17:16:14 -04:00
200699486a rest interface for retrieve-create users seed 2019-05-05 16:44:02 -04:00
503e31cc69 fix user ldap creation from bytes to string 2019-05-02 21:24:54 -04:00
86a082c29f Fix typho email verification 2019-05-02 17:36:31 -04:00
d07ff15f69 Add validation email before creation 2019-05-02 17:29:01 -04:00
c4079a1c1d request the username in login instead of the email 2019-05-02 04:10:06 -04:00
PCoder
1183573b65 Make cn, uid, uname the same 2019-05-02 00:31:13 +02:00
926b91ef97 fix password reset view 2019-05-01 17:48:24 -04:00
PCoder
3a88a98b95 Add logger + improve the way we build password reset url 2019-05-01 20:39:25 +02:00
PCoder
d0faf78168 Keep env.sample 2019-05-01 20:28:23 +02:00
f29ac4eb2f Added sending welcome email on user registration 2019-04-25 16:14:58 -04:00
019ac98249 added rest user creation 2019-04-23 01:19:45 -04:00
7848f07252 buttons block 2019-04-16 11:55:11 -04:00
942301d94d fix overflow-x 2019-04-16 11:52:58 -04:00
1e0fa89445 added red btn similar to blue one 2019-04-16 11:52:22 -04:00
163d977bc2 added styles to pages 2019-04-15 20:16:30 -04:00
PCoder
7191eb0997 Initialize checks_out variable to False (missing before) 2019-02-24 23:51:41 +01:00
PCoder
bcb3d6165d Logout user after password reset 2019-02-24 23:32:50 +01:00
PCoder
bdb57221e5 Also check user before password reset 2019-02-24 23:25:12 +01:00
PCoder
a5e91ffda2 Simplify search_base logic 2019-02-24 22:23:43 +01:00
PCoder
bf3b3b364f Get ENTIRE_SEARCH_BASE from env 2019-02-24 22:21:55 +01:00
PCoder
c0264e5dda Remove LoginRequiredMixin for ResetPassword view
As this can be done even when the user is logged out
2019-02-24 20:35:29 +01:00
PCoder
a20e9479c8 Add login_url for all LoginRequiredMixin views 2019-02-24 20:34:53 +01:00
PCoder
14949cedb7 Add register link to landing.html 2019-02-24 20:34:08 +01:00
PCoder
d4a02dc571 Remove unused imports 2019-02-24 20:16:10 +01:00
PCoder
5903e10d87 Redirect user to login page after logout 2019-02-24 20:15:52 +01:00
PCoder
f61023d01a Take user to logged in page when already authenticated 2019-02-24 20:14:49 +01:00
PCoder
c3b8f7b553 Add LoginRequiredMixin mixin for various views 2019-02-24 20:13:09 +01:00