discourse/app/models/concerns
Osama Sayegh eb5a3cfded
FEATURE: Add 2FA support to the Discourse Connect Provider protocol (#16386)
Discourse has the Discourse Connect Provider protocol that makes it possible to
use a Discourse instance as an identity provider for external sites. As a
natural extension to this protocol, this PR adds a new feature that makes it
possible to use Discourse as a 2FA provider as well as an identity provider.

The rationale for this change is that it's very difficult to implement 2FA
support in a website and if you have multiple websites that need to have 2FA,
it's unrealistic to build and maintain a separate 2FA implementation for each
one. But with this change, you can piggyback on Discourse to take care of all
the 2FA details for you for as many sites as you wish.

To use Discourse as a 2FA provider, you'll need to follow this guide:
https://meta.discourse.org/t/-/32974. It walks you through what you need to
implement on your end/site and how to configure your Discourse instance. Once
you're done, there is only one additional thing you need to do which is to
include `require_2fa=true` in the payload that you send to Discourse.

When Discourse sees `require_2fa=true`, it'll prompt the user to confirm their
2FA using whatever methods they've enabled (TOTP or security keys), and once
they confirm they'll be redirected back to the return URL you've configured and
the payload will contain `confirmed_2fa=true`. If the user has no 2FA methods
enabled however, the payload will not contain `confirmed_2fa`, but it will
contain `no_2fa_methods=true`.

You'll need to be careful to re-run all the security checks and ensure the user
can still access the resource on your site after they return from Discourse.
This is very important because there's nothing that guarantees the user that
will come back from Discourse after they confirm 2FA is the same user that
you've redirected to Discourse.

Internal ticket: t62183.
2022-04-13 15:04:09 +03:00
..
reports Add three reports (#14338) 2021-12-02 22:41:55 +05:30
anon_cache_invalidator.rb DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
cached_counting.rb PERF: perform all cached counting in background (#15991) 2022-02-22 16:45:25 +00:00
category_hashtag.rb FIX: Improve category hashtag lookup (#10133) 2020-07-07 10:19:01 +10:00
has_custom_fields.rb DEV: Clear custom field preload proxy on preload_custom_fields (#15671) 2022-01-21 14:29:51 +10:00
has_destroyed_web_hook.rb DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
has_sanitizable_fields.rb DEV: Sanitize HTML admin inputs (#14681) 2021-10-27 11:33:07 -03:00
has_search_data.rb DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
has_url.rb DEV: Make site setting type uploaded_image_list use upload IDs (#10401) 2020-10-13 16:17:06 +03:00
limited_edit.rb REFACTOR: Edit title respects min trust to edit post 2020-02-05 10:36:24 -07:00
positionable.rb DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
roleable.rb FEATURE: set notification levels when added to a group (#10378) 2020-08-06 12:27:27 -04:00
searchable.rb DEV: enable frozen string literal on all files 2019-05-13 09:31:32 +08:00
second_factor_manager.rb FEATURE: Add 2FA support to the Discourse Connect Provider protocol (#16386) 2022-04-13 15:04:09 +03:00
stats_cacheable.rb DEV: s/\$redis/Discourse\.redis (#8431) 2019-12-03 10:05:53 +01:00
topic_tracking_state_publishable.rb FEATURE: Publish read topic tracking events for private messages. (#14274) 2021-09-09 09:16:53 +08:00
trashable.rb DEV: Remove with_deleted workarounds for old Rails version (#11550) 2020-12-22 10:38:59 +11:00