]> git.openstreetmap.org Git - chef.git/commitdiff
Configure the OAuth 2 application ID for the web site
authorTom Hughes <tom@compton.nu>
Wed, 21 Jul 2021 10:30:42 +0000 (11:30 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 21 Jul 2021 11:04:28 +0000 (12:04 +0100)
cookbooks/dev/templates/default/rails.setup.rb.erb
cookbooks/web/recipes/rails.rb
cookbooks/web/resources/rails_port.rb

index ad42b68f723ed186eed5de0a80a436020c8f8d04..e2df25012bad810a7afddc3f1f66ad3f074f43b7 100644 (file)
@@ -51,4 +51,21 @@ OpenStreetMap::Application.config.after_initialize do
       OAUTH_KEY = website.key
     end
   end
+
+  if ActiveRecord::Base.connection.table_exists?(:oauth_applications)
+    unless website = webmaster.oauth2_applications.find_by_name("Web Site")
+      website = webmaster.oauth2_applications.new
+      website.name = "Web Site"
+      website.redirect_uri = "https://<%= @site %>/"
+      website.scopes = Oauth.scopes.map(&:name)
+      website.confidential = true
+      website.save!
+    end
+
+    if Kernel.const_defined?("Settings")
+      Settings.oauth_application = website.uid
+    else
+      OAUTH_APPLICATION = website.uid
+    end
+  end
 end
index 9956f099c65ad1fa25bdba5b8d49cbd92f26a1bc..e14c898c767fe1b6ad59fed1c19e1dc56a0775c7 100644 (file)
@@ -91,6 +91,7 @@ rails_port "www.openstreetmap.org" do
   potlatch2_key web_passwords["potlatch2_key"]
   id_key web_passwords["id_key"]
   oauth_key web_passwords["oauth_key"]
+  oauth_application web_passwords["oauth_application"]
   piwik_configuration "location" => piwik[:location],
                       "site" => piwik[:site],
                       "goals" => piwik[:goals].to_hash
index d275afede935da0d31b7c099382e35e5ed8d262c..16fde7131cc1e76758202521edb8f9afb25f0f8c 100644 (file)
@@ -52,6 +52,7 @@ property :memcache_servers, Array
 property :potlatch2_key, String
 property :id_key, String
 property :oauth_key, String
+property :oauth_application, String
 property :nominatim_url, String
 property :osrm_url, String
 property :google_auth_id, String
@@ -217,6 +218,10 @@ action :create do
       line.gsub!(/^( *)#oauth_key:.*$/, "\\1oauth_key: \"#{new_resource.oauth_key}\"")
     end
 
+    if new_resource.oauth_application
+      line.gsub!(/^( *)#oauth_application:.*$/, "\\1oauth_application: \"#{new_resource.oauth_application}\"")
+    end
+
     if new_resource.nominatim_url
       line.gsub!(/^( *)nominatim_url:.*$/, "\\1nominatim_url: \"#{new_resource.nominatim_url}\"")
     end
@@ -299,6 +304,7 @@ action :create do
     "potlatch2_key",
     "id_key",
     "oauth_key",
+    "oauth_application",
     "nominatim_url",
     "osrm_url",
     "google_auth_id",