# Future Social Authentication Improvements

**URL:** https://meta.discourse.org/t/future-social-authentication-improvements/94691
**Category:** Feature
**Created:** [8월 14, 2018, 10:20오전 UTC](https://meta.discourse.org/t/future-social-authentication-improvements/94691 "2018-08-14T10:20:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [8월 14, 2018, 10:20오전 UTC](https://meta.discourse.org/t/future-social-authentication-improvements/94691/1 "2018-08-14T10:20:55Z")

</div>

Discourse now has the ability to connect and disconnect different authentication providers to your account. This is good, but there is still more we can do. These are things I intended to do with my last round of improvements, but have not managed to complete before needing to move on to another project.

- Track ‘last used’ date for social login

- Log ‘connect’/‘revoke’ events in UserHistories

- [Provide statistics to administrators](https://meta.discourse.org/t/statistics-regarding-registrations-native-versus-external/14442/3)

As @fantasticfears pointed out [here](https://meta.discourse.org/t/ability-to-connect-with-oauth-providers-when-user-is-registered/42457/3), features like this are difficult to implement with the current data structure. We should try and consolidate this information into one table, and share as much logic between providers as possible.

> [@Ability to connect with OAuth providers when user is registered?](https://meta.discourse.org/t/ability-to-connect-with-oauth-providers-when-user-is-registered/42457/3):
>
> Now, Discourse has `{google,facebook,github,instagram,twitter}_user_info` . Plugins can use `oauth2_user_info` or `PluginRow` . I would say a new model can represent all those information

An improved system would be a `user_associated_accounts` table. Columns are based on the omniauth ‘auth hash schema’ [Auth Hash Schema · omniauth/omniauth Wiki · GitHub](https://github.com/omniauth/omniauth/wiki/Auth-Hash-Schema). Email and nickname have dedicated columns as well as the ‘info’ column, so that they can be easily accessed.

- provider\_name (not null) ( **omniauth ‘provider’ - required** )
- provider\_uid (not null) ( **omniauth ‘uid’ - required’** )
- user\_id (not null)
- last\_used (not null)
- info (jsonb) ( **omniauth ‘info’** )
- credentials (jsonb) ( **omniauth ‘credentials’** )
- extra (jsonb) ( **omniauth ‘extra’** )

The tricky bit here will be migrating data to the new structure, and updating plugins accordingly. It’s not a small amount of work, but I think it would be worth it.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [8월 16, 2018, 12:49오전 UTC](https://meta.discourse.org/t/future-social-authentication-improvements/94691/2 "2018-08-16T00:49:29Z")

</div>

I very much support this change. In this very specific case I also support an extra column in the table for “extra auth provider data” so we have some flexibility.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [1월 16, 2019, 2:00오후 UTC](https://meta.discourse.org/t/future-social-authentication-improvements/94691/3 "2019-01-16T14:00:39Z")

</div>

This framework for this is now in place. Core Facebook and Twitter authenticators have been migrated, and other authenticators will follow over the coming weeks. Documentation can be found here: [Adding a new 'managed' authentication method to Discourse](https://meta.discourse.org/t/adding-a-new-managed-authentication-method-to-discourse/106695)

There is no plan to prevent use of the old system, but it is highly recommended that plugins do migrated, so that complex account association logic can be shared.

I’ll use this topic to track the migrations of core/official-plugin authenticators:

**Core:**  
 [Facebook](https://github.com/discourse/discourse/commit/208005f9c9662773b436c4ffa14272ac0888bb04)  
 [Twitter](https://github.com/discourse/discourse/commit/160d29b18a0ff68f0cdc152b9d5f461869190b7e)  
 [Github](https://github.com/discourse/discourse/pull/11170)  
 [Google](https://github.com/discourse/discourse/commit/fc7938f7e081318ad52462bd2aa1c95e61fb5d03)  
 [Instagram](https://github.com/discourse/discourse/commit/703c724cf3adff0feb89f99be30f4fb4ed540e22)  
 ~~Yahoo~~

**Official Plugins:**  
 OpenID Connect  
 [OAuth 2](https://meta.discourse.org/t/oauth2-basic-support/33879/189)  
 Discord (moved to core)  
 Patreon  
 LinkedIn  
~~[] Ubuntu~~ (deprecated)  
 SAML  
~~[] Azure-AD~~ (deprecated)  
 ~~Office365~~ Microsoft Auth  
 Atlassian Crowd  
 Steam  
~~[] Dwolla~~ (deprecated)
