mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:21:04 +08:00
REFACTOR: Serve auth provider information in the site serializer.
At the moment core providers are hard-coded in Javascript, and plugin providers get added to the JS payload at compile time. This refactor means that we only ship enabled providers to the client.
This commit is contained in:
@ -200,12 +200,27 @@ module Discourse
|
||||
end
|
||||
end
|
||||
|
||||
BUILTIN_AUTH = [
|
||||
Auth::AuthProvider.new(authenticator: Auth::FacebookAuthenticator.new, frame_width: 580, frame_height: 400),
|
||||
Auth::AuthProvider.new(authenticator: Auth::GoogleOAuth2Authenticator.new, frame_width: 850, frame_height: 500),
|
||||
Auth::AuthProvider.new(authenticator: Auth::OpenIdAuthenticator.new("yahoo", "https://me.yahoo.com", 'enable_yahoo_logins', trusted: true)),
|
||||
Auth::AuthProvider.new(authenticator: Auth::GithubAuthenticator.new),
|
||||
Auth::AuthProvider.new(authenticator: Auth::TwitterAuthenticator.new),
|
||||
Auth::AuthProvider.new(authenticator: Auth::InstagramAuthenticator.new, frame_width: 1, frame_height: 1)
|
||||
]
|
||||
|
||||
def self.auth_providers
|
||||
BUILTIN_AUTH + DiscoursePluginRegistry.auth_providers.to_a
|
||||
end
|
||||
|
||||
def self.enabled_auth_providers
|
||||
auth_providers.select { |provider| provider.authenticator.enabled? }
|
||||
end
|
||||
|
||||
def self.authenticators
|
||||
# NOTE: this bypasses the site settings and gives a list of everything, we need to register every middleware
|
||||
# for the cases of multisite
|
||||
# In future we may change it so we don't include them all for cases where we are not a multisite, but we would
|
||||
# require a restart after site settings change
|
||||
Users::OmniauthCallbacksController::BUILTIN_AUTH + DiscoursePluginRegistry.auth_providers.map(&:authenticator)
|
||||
auth_providers.map(&:authenticator)
|
||||
end
|
||||
|
||||
def self.enabled_authenticators
|
||||
|
Reference in New Issue
Block a user