未来社交认证改进

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.

As @fantasticfears pointed out here, 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.

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. 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.

20 个赞

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.

7 个赞

此框架现已就位。核心 Facebook 和 Twitter 认证器已完成迁移,其他认证器将在未来几周内陆续迁移。相关文档可在此查阅:Adding a new 'managed' authentication method to Discourse

目前并无计划阻止旧系统的使用,但强烈建议插件进行迁移,以便共享复杂的账户关联逻辑。

我将利用此主题追踪核心/官方插件认证器的迁移进度:

核心:
Facebook
Twitter
Github
Google
Instagram
Yahoo

官方插件:
OpenID Connect
OAuth 2
Discord(已移至核心)
Patreon
LinkedIn
[ ] Ubuntu(已弃用)
SAML
[ ] Azure-AD(已弃用)
Office365 Microsoft Auth
Atlassian Crowd
Steam
[ ] Dwolla(已弃用)

14 个赞