Commit graph

203 commits

Author SHA1 Message Date
Pēteris Caune
a2c7259d1b
Fix redirects after login when using a path in SITE_ROOT
Fixes: #382

cc: #1091
2024-12-09 12:35:02 +02:00
Pēteris Caune
fd96cc794b
Remove unused bits 2024-10-04 17:34:30 +03:00
Pēteris Caune
1bdfbac775
Fix Sign In page to hide "Email Link" option if SMTP is not configured
Fixes: #922
2024-05-10 11:04:21 +03:00
Pēteris Caune
a4d2094cef
Update the remove_project view to delete checks using lock_and_delete()
If we delete project by naively calling project.delete() then checks
can receive pings during the deletion, causing the deletion operation
to fail with an IntegrityError.

So instead do it like so:

* iterate over project's checks, call Check.lock_and_delete() on each
* in the end, call project.delete()
2024-04-16 16:36:49 +03:00
moraj-turing
3718ff57c7
Add support for system theme (#987)
Add support for system theme

---------

Co-authored-by: Juan Mora <juan@nimble.gt>
Co-authored-by: Pēteris Caune <cuu508@gmail.com>
2024-04-15 10:42:16 +03:00
Pēteris Caune
33e58fa014
Change the signup flow to accept registered users
(and sign them in instead)
2024-03-15 17:30:06 +02:00
Pēteris Caune
96823a7f90
Add logging for failed webauthn key registrations 2023-11-17 16:06:39 +02:00
Pēteris Caune
7e7cbe9f75
Fix the Login form to not perform form validation in GET requests 2023-10-22 10:45:06 +03:00
Pēteris Caune
30a3a784c3
Move AuthenticatedHttpRequest to hc.accounts.http module
If AuthenticatedHttpRequest lives in the hc.lib.typealias
module then hc.lib.typealias imports User and Profile,
and so needs configured Django settings. Most of the stuff
in hc.lib is intended to work standalone, and not rely on Django.
2023-10-21 18:16:48 +03:00
Pēteris Caune
e9ac841d01
Move reusable type aliases to hc.lib.typealias 2023-09-06 10:52:47 +03:00
Pēteris Caune
65b3acf964
Improve type hints in hc.accounts.views 2023-09-06 10:02:50 +03:00
Pēteris Caune
0c83ca4fd8
Improve type hints in hc.accounts.forms 2023-09-05 18:31:35 +03:00
Pēteris Caune
26725b9f4e
Add an "Account closed." confirmation message after closing an account 2023-08-24 09:07:41 +03:00
Pēteris Caune
4ccee09f73
Add /api/v3/ (adds ability to set slug when creating or updating checks) 2023-06-14 16:52:45 +03:00
Pēteris Caune
518dee4ae2
Update the login_webauthn view to return HTTP 404 when RP_ID is not set 2023-06-08 10:49:57 +03:00
Pēteris Caune
d84a97acef
Add @sensitive_post_parameters() to views that handle passwords 2023-02-20 10:09:16 +02:00
Pēteris Caune
423dac4b19
Add a protection for non-bool settings.SESSION_COOKIE_SECURE value 2023-02-15 09:20:00 +02:00
Pēteris Caune
3d728325fe
Fix the SameSite and Secure attributes on the "auto-login" cookie
The "auto-login" cookie is a part of a work-around for
some email clients automatically clicking links in emails:

- when sending an one-time sign-in link, server also sends the
  "auto-login" cookie to the client
- when end user clicks on the sign-in link, the server checks
  if client's request contains the "auto-login" cookie
- if the "auto-login" cookie is present, log the user in
- if the "auto-login" cookie is absent, serve a HTTP POST form
  with a submit button. The user must click the button to log in.

This commit fixes attributes on the "auto-login" cookie:

- it sets SameSite=Lax
- it sets Secure=true if SESSION_COOKIE_SECURE=True
2023-02-15 09:17:09 +02:00
Pēteris Caune
c8750ad05b
Fix the signup form to work with httpOnly CSRF cookies 2023-02-14 14:20:27 +02:00
Pēteris Caune
e46cf3725b
Add CSRF protection in the signup view 2023-02-14 09:15:46 +02:00
Pēteris Caune
737405679f
Fix EmailLoginForm initialization 2023-01-23 14:53:49 +02:00
Pēteris Caune
2cfb37f097
Add rate limiting by client IP in the signup and login views 2023-01-23 14:35:45 +02:00
Pēteris Caune
359edbd270
Fix login and signup views to make email enumeration harder 2023-01-23 13:05:49 +02:00
Pēteris Caune
18c17fb4b5
Fix project sort order to be case-insensitive everywhere in the UI
Fixes: #768
2022-12-22 11:39:20 +02:00
Pēteris Caune
15cbb39bd3
Change "Settings - Email Reports" page to allow manual tz selection 2022-12-01 16:12:32 +02:00
Pēteris Caune
a65aa171f4
Replace var=[...];if var: [...] usages with the walrus operator 2022-12-01 09:16:19 +02:00
Pēteris Caune
161430fb10
Sort imports and add "from __future__ import annotations" 2022-10-17 16:52:15 +03:00
Pēteris Caune
f371561fe5
Update the logout action to use HTTP POST 2022-08-08 15:16:24 +03:00
Pēteris Caune
438c94efb7
Fix a race condition in the "Change Email" flow
The race scenario was as follows:

* Alice initiates email address change to bob@example.org
* a verification link is sent to bob@example.org
* separately, somebody creates a new account for bob@example.org
* Alice clicks on the verification link

At this point,
- if the database has an uniqueness constraint on auth_user.email,
  Alice will receive a HTTP 500 error
- if there's no uniqueness constraint, the email change
  will succeed and the system will have two accounts with the
  same email address

The simple fix is to re-check the address availability just
before finalizing the email address change. Currently this is
not done in a transaction block, so the race condition still
exists in theory, but is much less likely to happen in practice.
2022-07-21 15:14:51 +03:00
Pēteris Caune
2b623453c1
Update tests 2022-06-19 12:31:27 +03:00
Pēteris Caune
a4c4df976c
Split the helper class in GetHelper and CreateHelper 2022-06-19 11:30:37 +03:00
Pēteris Caune
57021e962c
Refactor webauthn implementation, use webauthn-json 2022-06-19 10:10:57 +03:00
Pēteris Caune
901f944055
Test pyflakes warnings 2022-05-26 21:39:53 +03:00
Pēteris Caune
6790d867a6
Add address verification step in the "Change Email" flow
A similar issue has come up multiple times: the user
changes account's email address, enters a bad address
by mistake, and gets locked out of their account.

This commit adds an extra step in the "Change Email" flow:

* In "Account Settings", user clicks on [Change Email]
* User gets a prompt for a 6-digit confirmation code, which
  has been sent to their old address. This is to prevent
  account takeover when Eve sits down at a computer where Alice
  is logged in.
* The user enters the confirmation code, and a "Change Email"
  form loads.
* The user enters their new email address.
* (The new step!) Instead of changing the email right away,
  we send a special login link to user's specified new address.
* (The new step, continued) The user clicks on the login link,
  their account's email address gets updated, and they get
  logged in.

The additional step makes sure the user can receive email
at their new address. If they cannot receive email there,
they cannot complete the "Change Email" procedure.
2022-05-20 17:54:45 +03:00
Pēteris Caune
3f521b16f7
Make email non-editable in "Invite Member" when team limit reached
There is a specific limit of how many other users a given user
can invite in their projects (depends on the plan they are on).
When the limit is reached, the user cannot invite *new* users
in their projects, but they can still invite team members
from one project into another project. In other words, we count
the number of unique invited users, not the number of memberships.

There was an UI bug in the "Invite a Team Member" dialog. The
dialog has an editable "Email" text field. When an user has reached
the team limit, and they open the "Invite" dialog, they could
enter a new user's email address in the Email field and try to invite
them. The server would refuse to exceed the team limit and would
return a plain HTTP 403 page. This is of course confusing to the 
end user.

The fix is to show "Email" as a text field only if the user has
not yet exceeded their team size. If they have, then show "Email"
as non-editable text.
2022-02-04 20:43:17 +02:00
Pēteris Caune
e5ac8d7dbc
Update the "Add TOTP" form to display plaintext TOTP secret
Fixes: #602
2022-01-24 15:17:48 +02:00
Pēteris Caune
9e36eb5fcc
Remove the "welcome" landing page
Redirect unauthenticated users to the sign in page
instead. Rationale:

- The content on the welcome page is what often belongs
  to a separate "marketing site". The marketing content
  is of no use on self-hosted instances, which typically
  have new signups disabled and are for internal use only
- (the real reason, let's be honest) a number of
  self-hosted instances are accessible over the public
  internet. Search engines index the nearly identical
  landing pages and see them as duplicated content.
2021-11-10 11:59:55 +02:00
Pēteris Caune
3dfdbc09ca
Add ability to create/revoke individual keys 2021-09-09 14:55:17 +03:00
Pēteris Caune
5b9008e321
Implement alternative ping URLs, WIP 2021-09-09 09:32:10 +03:00
Pēteris Caune
1247cc4ea7
Fix a crash during login when user's profile does not exist
Fixes: #77
2021-08-18 10:32:10 +03:00
Pēteris Caune
af7e8fc949
Fix the login view to handle already authenticated users
If an already authenticated user visits /accounts/login/,
Healthchecks will now redirect them to their dashboard
instead of showing the login form.
2021-08-06 13:54:12 +03:00
Pēteris Caune
7252f2f101
Fix _allow_redirect function to reject absolute URLs
This fixes a security issue:
- attacker can crafts a redirect URL to an external site
- attacker gets victim to click on it
- victim logs in
- after login, Healthchecks redirects victim to the external site

The _allow_redirect function now additionally
requires the redirect URL is relative (has no scheme or domain).
2021-08-06 13:34:40 +03:00
Pēteris Caune
f85aec225d
Fix redirect-after-login when using TOTP
If user has both WebAuthn and TOTP configured,
when logging in, they will be asked to choose between
"Use security keys" and "Use authenticator app".
The "Use authenticator app" is a link to a different
page (/accounts/login/two_factor/totp/). This commit makes
sure the ?next= query parameter is preserved when navigating
to that page.

For reference, the ?next= query parameter is the URL we should
redirect to after a successful login. Use case:
User is logged out. They click on a bookmarked "Check Details"
link. They get redirected to the login form. After
entering username & password and completing 2FA,
they get redirected to the "Check Details" page they
originally wanted to visit.
2021-08-06 12:09:41 +03:00
Pēteris Caune
c3d458f6f0
Fix the unsubscribe_reports view to handle already deleted users 2021-08-02 12:51:05 +03:00
Pēteris Caune
d60d8a43b6
Add protection against TOTP code reuse 2021-07-30 18:17:21 +03:00
Pēteris Caune
8ed5e93cd2
Add rate limiting for TOTP auth attempts 2021-07-30 17:30:28 +03:00
Pēteris Caune
222722569e
Add support for 2FA using TOTP
Fixes: #354
2021-07-30 16:43:23 +03:00
Pēteris Caune
bbd2786e0f
Optimize queries and fix team member sorting 2021-07-26 14:27:03 +03:00
Pēteris Caune
4f83f8c06b
Fix a 403 when transferring a project to a read-only team member 2021-07-26 12:50:43 +03:00
swoga
9640d2242f feat: add manager role 2021-07-26 12:26:06 +03:00