Sha256: 4a96abca49bc42c1d95b60f7ae693f3e4710f2f28a583217fe6d20fe80e0f403
Contents?: true
Size: 1.56 KB
Versions: 9
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true def setup_provider_proc(provider, config_mapping = {}) lambda do |env| request = Rack::Request.new(env) organization = Decidim::Organization.find_by(host: request.host) provider_config = organization.enabled_omniauth_providers[provider] config_mapping.each do |option_key, config_key| env["omniauth.strategy"].options[option_key] = provider_config[config_key] end end end Rails.application.config.middleware.use OmniAuth::Builder do omniauth_config = Rails.application.secrets.dig(:omniauth) if omniauth_config if omniauth_config[:developer].present? provider( :developer, fields: [:name, :nickname, :email] ) end if omniauth_config[:decidim].present? provider( :decidim, setup: setup_provider_proc(:decidim, client_id: :client_id, client_secret: :client_secret, site: :site_url) ) end if omniauth_config[:facebook].present? provider( :facebook, setup: setup_provider_proc(:facebook, client_id: :app_id, client_secret: :app_secret), scope: :email, info_fields: "name,email,verified" ) end if omniauth_config[:twitter].present? provider( :twitter, setup: setup_provider_proc(:twitter, consumer_key: :api_key, consumer_secret: :api_secret) ) end if omniauth_config[:google_oauth2].present? provider( :google_oauth2, setup: setup_provider_proc(:google_oauth2, client_id: :client_id, client_secret: :client_secret) ) end end end
Version data entries
9 entries across 9 versions & 1 rubygems