# 将来のソーシャル認証機能の改善

**URL:** <https://meta.discourse.org/t/future-social-authentication-improvements/94691>\
**Category:** Feature\
**Created:** [2018 年 8 月 14 日午前 10:20 UTC](https://meta.discourse.org/t/future-social-authentication-improvements/94691 "2018-08-14T10:20:55Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [2018 年 8 月 14 日午前 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.

---

_[View the full topic](https://meta.discourse.org/t/future-social-authentication-improvements/94691)._
