SEED-platform / seed

Standard Energy Efficiency Data (SEED) Platform™ is a web-based application that helps organizations easily manage data on the energy performance of large groups of buildings.
Other
106 stars 55 forks source link

Add 2 Factor Authentication #4700

Open perryr16 opened 1 week ago

perryr16 commented 1 week ago

Any background context you want to provide?

What's this PR do?

Adds Two Factor Authentication features to the login process using Django-Two-Factor-Auth as a base. The Django-Two-Factor Auth (django-2fa) library is built on top of the django-otp library.

The login process is handled through django-2fa, however two-factor method configuration is handled locally on SEED with the help of qrcode and pyotp libraries.

Users who have logged in for the first time following these changes will be redirected to the two factor profile page where they can set their method of choice. Following log ins will direct to the SEED homepage.

This PR introduces a new org setting to require all users to use a two factor authentication method. If this method is set, all active users who do not already have a 2fa method set will be assigned email verification with the option to switch to any token auth app. User's part of multiple orgs will be required to use 2fa if any parent org 2fa requirement is set.

To set up the Authenticator App Token method, users must scan a generated QR code and verify the code from the authenticator app. If the code is not verified, a default method will be assigned based on the 2fa requirement org setting.

How should this be manually tested?

What are the relevant tickets?

4581

Screenshots (if appropriate)

Screenshot 2024-06-24 at 9 51 15 AM

Screenshot 2024-06-24 at 9 36 26 AM

Screenshot 2024-06-24 at 10 38 37 AM