diff --git a/app/views/shared/_social_media_meta_tags.html.erb b/app/views/shared/_social_media_meta_tags.html.erb
index 01811be41..bd7117708 100644
--- a/app/views/shared/_social_media_meta_tags.html.erb
+++ b/app/views/shared/_social_media_meta_tags.html.erb
@@ -17,4 +17,4 @@
" />
" />
-
+
diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb
index aeb30c2f1..e297bfd48 100644
--- a/config/initializers/devise.rb
+++ b/config/initializers/devise.rb
@@ -245,14 +245,26 @@ Devise.setup do |config|
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
# config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
- config.omniauth :twitter, Rails.application.secrets.twitter_key, Rails.application.secrets.twitter_secret
- config.omniauth :facebook, Rails.application.secrets.facebook_key, Rails.application.secrets.facebook_secret, scope: "email", info_fields: "email,name,verified"
- config.omniauth :google_oauth2, Rails.application.secrets.google_oauth2_key, Rails.application.secrets.google_oauth2_secret
+ config.omniauth :twitter,
+ Rails.application.secrets.twitter_key,
+ Rails.application.secrets.twitter_secret,
+ setup: OmniauthTenantSetup.twitter
+ config.omniauth :facebook,
+ Rails.application.secrets.facebook_key,
+ Rails.application.secrets.facebook_secret,
+ scope: "email",
+ info_fields: "email,name,verified",
+ setup: OmniauthTenantSetup.facebook
+ config.omniauth :google_oauth2,
+ Rails.application.secrets.google_oauth2_key,
+ Rails.application.secrets.google_oauth2_secret,
+ setup: OmniauthTenantSetup.google_oauth2
config.omniauth :wordpress_oauth2,
Rails.application.secrets.wordpress_oauth2_key,
Rails.application.secrets.wordpress_oauth2_secret,
strategy_class: OmniAuth::Strategies::Wordpress,
- client_options: { site: Rails.application.secrets.wordpress_oauth2_site }
+ client_options: { site: Rails.application.secrets.wordpress_oauth2_site },
+ setup: OmniauthTenantSetup.wordpress_oauth2
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
diff --git a/config/secrets.yml.example b/config/secrets.yml.example
index c6d29ec3b..d04c93778 100644
--- a/config/secrets.yml.example
+++ b/config/secrets.yml.example
@@ -57,8 +57,8 @@ staging:
# my_tenant_subdomain:
# secret_key: my_secret_value
#
- # Currently you can overwrite SMTP, SMS, manager, microsoft API and
- # HTTP basic settings.
+ # Currently you can overwrite SMTP, SMS, manager, microsoft API,
+ # HTTP basic, twitter, facebook, google and wordpress settings.
<<: *maps
<<: *apis
@@ -93,8 +93,8 @@ preproduction:
# my_tenant_subdomain:
# secret_key: my_secret_value
#
- # Currently you can overwrite SMTP, SMS, manager, microsoft API and
- # HTTP basic settings.
+ # Currently you can overwrite SMTP, SMS, manager, microsoft API,
+ # HTTP basic, twitter, facebook, google and wordpress settings.
twitter_key: ""
twitter_secret: ""
facebook_key: ""
@@ -134,8 +134,8 @@ production:
# my_tenant_subdomain:
# secret_key: my_secret_value
#
- # Currently you can overwrite SMTP, SMS, manager, microsoft API and
- # HTTP basic settings.
+ # Currently you can overwrite SMTP, SMS, manager, microsoft API,
+ # HTTP basic, twitter, facebook, google and wordpress settings.
twitter_key: ""
twitter_secret: ""
facebook_key: ""
diff --git a/lib/omniauth_tenant_setup.rb b/lib/omniauth_tenant_setup.rb
new file mode 100644
index 000000000..57d010947
--- /dev/null
+++ b/lib/omniauth_tenant_setup.rb
@@ -0,0 +1,47 @@
+module OmniauthTenantSetup
+ class << self
+ def twitter
+ ->(env) do
+ oauth(env, secrets.twitter_key, secrets.twitter_secret)
+ end
+ end
+
+ def facebook
+ ->(env) do
+ oauth2(env, secrets.facebook_key, secrets.facebook_secret)
+ end
+ end
+
+ def google_oauth2
+ ->(env) do
+ oauth2(env, secrets.google_oauth2_key, secrets.google_oauth2_secret)
+ end
+ end
+
+ def wordpress_oauth2
+ ->(env) do
+ oauth2(env, secrets.wordpress_oauth2_key, secrets.wordpress_oauth2_secret)
+ end
+ end
+
+ private
+
+ def oauth(env, key, secret)
+ unless Tenant.default?
+ env["omniauth.strategy"].options[:consumer_key] = key
+ env["omniauth.strategy"].options[:consumer_secret] = secret
+ end
+ end
+
+ def oauth2(env, key, secret)
+ unless Tenant.default?
+ env["omniauth.strategy"].options[:client_id] = key
+ env["omniauth.strategy"].options[:client_secret] = secret
+ end
+ end
+
+ def secrets
+ Tenant.current_secrets
+ end
+ end
+end