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:
David Taylor
2018-07-31 16:18:50 +01:00
parent 4e11811321
commit 812add18bd
24 changed files with 184 additions and 215 deletions

28
lib/auth/auth_provider.rb Normal file
View File

@@ -0,0 +1,28 @@
class Auth::AuthProvider
include ActiveModel::Serialization
def initialize(params = {})
params.each { |key, value| send "#{key}=", value }
end
def self.auth_attributes
[:pretty_name, :title, :message, :frame_width, :frame_height, :authenticator,
:pretty_name_setting, :title_setting, :enabled_setting, :full_screen_login, :full_screen_login_setting,
:custom_url]
end
attr_accessor(*auth_attributes)
def name
authenticator.name
end
def can_connect
authenticator.can_connect_existing_user?
end
def can_revoke
authenticator.can_revoke?
end
end