OSDN Git Service

Allow the OmniAuth provider args parameter to pass through as either an Array or...
authorAaron Stone <aaron@serendipity.cx>
Sun, 23 Dec 2012 15:49:11 +0000 (07:49 -0800)
committerAaron Stone <aaron@serendipity.cx>
Mon, 24 Dec 2012 00:12:53 +0000 (16:12 -0800)
config/gitlab.yml.example
config/initializers/devise.rb

index f47625e..786a32c 100644 (file)
@@ -66,6 +66,8 @@ omniauth:
   # Uncomment the lines and fill in the data of the auth provider you want to use
   # If your favorite auth provider is not listed you can user others:
   # see https://github.com/gitlabhq/gitlabhq/wiki/Using-Custom-Omniauth-Providers
+  # The 'app_id' and 'app_secret' parameters are always passed as the first two
+  # arguments, followed by optional 'args' which can be either a hash or an array.
   providers:
     # - { name: 'google_oauth2', app_id: 'YOUR APP ID',
     #     app_secret: 'YOUR APP SECRET',
index ed3ab71..97946c5 100644 (file)
@@ -217,6 +217,15 @@ Devise.setup do |config|
   end
 
   Gitlab.config.omniauth.providers.each do |provider|
-    config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret']
+    case provider['args']
+    when Array
+      # An Array from the configuration will be expanded.
+      config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], *provider['args']
+    when Hash
+      # A Hash from the configuration will be passed as is.
+      config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret'], provider['args']
+    else
+      config.omniauth provider['name'].to_sym, provider['app_id'], provider['app_secret']
+    end
   end
 end