This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts
Osama Sayegh dd6ec65061
FEATURE: Centralized 2FA page (#15377)
2FA support in Discourse was added and grown gradually over the years: we first
added support for TOTP for logins, then we implemented backup codes, and last
but not least, security keys. 2FA usage was initially limited to logging in,
but it has been expanded and we now require 2FA for risky actions such as
adding a new admin to the site.

As a result of this gradual growth of the 2FA system, technical debt has
accumulated to the point where it has become difficult to require 2FA for more
actions. We now have 5 different 2FA UI implementations and each one has to
support all 3 2FA methods (TOTP, backup codes, and security keys) which makes
it difficult to maintain a consistent UX for these different implementations.
Moreover, there is a lot of repeated logic in the server-side code behind these
5 UI implementations which hinders maintainability even more.

This commit is the first step towards repaying the technical debt: it builds a
system that centralizes as much as possible of the 2FA server-side logic and
UI. The 2 main components of this system are:

1. A dedicated page for 2FA with support for all 3 methods.
2. A reusable server-side class that centralizes the 2FA logic (the
`SecondFactor::AuthManager` class).

From a top-level view, the 2FA flow in this new system looks like this:

1. User initiates an action that requires 2FA;

2. Server is aware that 2FA is required for this action, so it redirects the
user to the 2FA page if the user has a 2FA method, otherwise the action is
performed.

3. User submits the 2FA form on the page;

4. Server validates the 2FA and if it's successful, the action is performed and
the user is redirected to the previous page.

A more technically-detailed explanation/documentation of the new system is
available as a comment at the top of the `lib/second_factor/auth_manager.rb`
file. Please note that the details are not set in stone and will likely change
in the future, so please don't use the system in your plugins yet.

Since this is a new system that needs to be tested, we've decided to migrate
only the 2FA for adding a new admin to the new system at this time (in this
commit). Our plan is to gradually migrate the remaining 2FA implementations to
the new system.

For screenshots of the 2FA page, see PR #15377 on GitHub.
2022-02-17 12:12:59 +03:00
..
admin FEATURE: Centralized 2FA page (#15377) 2022-02-17 12:12:59 +03:00
confirm-new-email DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
discourse FEATURE: Centralized 2FA page (#15377) 2022-02-17 12:12:59 +03:00
discourse-common DEV: Add chat_quoted notification type (#15968) 2022-02-16 15:22:08 +10:00
discourse-hbr PERF: Update ember-auto-import and webpack (#15919) 2022-02-14 11:21:39 +00:00
discourse-widget-hbs PERF: Update ember-auto-import and webpack (#15919) 2022-02-14 11:21:39 +00:00
docs DEV: enforces eslint’s curly rule to the codebase (#10720) 2020-09-22 16:28:28 +02:00
ember-addons DEV: Remove ember-addons (#9559) 2020-04-28 10:14:49 -04:00
locales DEV: Add count to missing translation strings (#15509) 2022-01-09 23:10:32 +01:00
pretty-text FIX: Load short upload URLs only once (#15918) 2022-02-16 08:57:20 +02:00
select-kit FEATURE: Use new topic-chooser for invite modal (#15884) 2022-02-14 13:43:52 +02:00
truth-helpers PERF: Update ember-auto-import and webpack (#15919) 2022-02-14 11:21:39 +00:00
wizard DEV: Refactor animation for invalid inputs in wizard (#15334) 2021-12-16 17:17:36 -05:00
.npmrc DEV: Prevent npm usage (#13945) 2021-08-04 22:04:58 +02:00
activate-account.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
admin.js.erb FIX: Load .js files from plugins in qunit testing env (#11304) 2020-12-03 10:25:42 -06:00
app-boot.js REFACTOR: Sync up master with changes for Ember-CLI (#11671) 2021-01-12 10:13:21 -05:00
application.js DEV: Make screen-track a regular service (#14983) 2021-11-17 20:56:06 +01:00
auto-redirect.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
browser-detect.js FIX: Feature detect globalThis (#14410) 2021-09-22 11:39:41 -03:00
browser-update.js FIX: browser-update should work with old browsers (#12436) 2021-03-18 19:09:01 +02:00
discourse-loader.js Revert "A11Y: Improve create account modal for screen readers (#14204)" (#14233) 2021-09-03 09:42:56 +10:00
discourse-shims.js FEATURE: Local chunked uppy backup uploads with a new uploader plugin (#14894) 2021-11-23 08:45:42 +10:00
embed-application.js DEV: prettier 2.2.1 (#11862) 2021-01-27 12:39:20 +01:00
ember_include.js.erb DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
ember_jquery.js Revert "Revert "DEV: Import MessageBus from message-bus-client instead of globals"" 2020-05-28 08:42:36 -04:00
env.js FIX: attempts to fix an error with EXTEND_PROTOTYPES (#7067) 2019-02-26 11:04:05 +01:00
google-tag-manager.js FEATURE: Implement nonces for Google Tag Manager integration (#12531) 2021-03-26 11:19:31 -04:00
google-universal-analytics-v3.js FEATURE: Add Google Universal Analytics v4 as an option (#11123) 2020-11-06 14:15:36 -06:00
google-universal-analytics-v4.js FEATURE: Add Google Universal Analytics v4 as an option (#11123) 2020-11-06 14:15:36 -06:00
handlebars-shim.js FIX: It seems sometimes shims are evaluated by older JS engines (#11813) 2021-01-22 10:41:01 -05:00
main_include_admin.js DEV: Remove old backup uploader and resumable.js (#15365) 2021-12-21 15:02:10 +10:00
markdown-it-bundle.js REFACTOR: Do not rely on module order for discourse-markdown loading 2020-09-18 13:31:55 -04:00
onpopstate-handler.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
package.json FIX: Make truth-helpers work in Ember CLI (#13044) 2021-05-12 17:52:36 +02:00
polyfills.js DEV: Remove iOS 9.3 polyfills (#15343) 2021-12-17 02:47:13 +01:00
pretty-text-bundle.js FIX: pretty text allow list (#10977) 2020-10-28 13:22:06 +11:00
print-page.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
service-worker.js.erb FIX: Disable service worker proxying in chrome 97-97.0.4692 (#15638) 2022-01-18 19:41:25 +00:00
set-prototype-polyfill.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
start-discourse.js DEV: Avoid using globals (#14909) 2021-11-13 13:10:13 +01:00
template_include.js DEV: Support for import Handlebars from 'handlebars'; (#9600) 2020-04-30 16:41:02 -04:00
test-shims.js DEV: Migrate to Ember CLI (#11932) 2021-02-03 14:22:20 -05:00
vendor-common.js DEV: Remove jQuery UI vendor dependencies (#15700) 2022-01-28 11:21:59 +11:00
vendor-theme-tests.js DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
vendor.js DEV: Support for running theme test with Ember CLI (third attempt) 2022-01-13 16:02:07 -05:00
widget-runtime.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
wizard-application.js DEV: implements some of ember-truth-helpers (#12667) 2021-04-12 11:40:00 +02:00
wizard-shims.js DEV: Use Uppy in wizard-field-image uploads (#15269) 2021-12-13 15:23:44 +10:00
wizard-start.js DEV: apply new coding standards (#10592) 2020-09-04 13:42:47 +02:00
wizard-vendor.js DEV: Remove jQuery UI vendor dependencies (#15700) 2022-01-28 11:21:59 +11:00
yarn.lock PERF: Update ember-auto-import and webpack (#15919) 2022-02-14 11:21:39 +00:00