]> git.openstreetmap.org Git - chef.git/blob - cookbooks/dev/templates/default/rails.setup.rb.erb
apache: increase mod_evasive page_count to reduce iD false positives
[chef.git] / cookbooks / dev / templates / default / rails.setup.rb.erb
1 OpenStreetMap::Application.config.after_initialize do
2   unless webmaster = User.find_by_email("webmaster@openstreetmap.org")
3     webmaster = User.new
4     webmaster.display_name = "OpenStreetMap Webmaster"
5     webmaster.email = "webmaster@openstreetmap.org"
6     webmaster.pass_crypt = SecureRandom.hex
7     webmaster.activate
8     webmaster.save!
9   end
10
11   if ActiveRecord::Base.connection.table_exists?(:client_applications)
12     unless id = webmaster.client_applications.find_by_name("iD")
13       id = webmaster.client_applications.new
14       id.name = "iD"
15       id.url = "https://<%= @site %>/"
16       ClientApplication.all_permissions.each { |p| id[p] = true }
17       id.save!
18     end
19
20     if Kernel.const_defined?("Settings")
21       Settings.id_key = id.key
22     else
23       ID_KEY = id.key
24     end
25
26     unless potlatch = webmaster.client_applications.find_by_name("Potlatch 2")
27       potlatch = webmaster.client_applications.new
28       potlatch.name = "Potlatch 2"
29       potlatch.url = "https://<%= @site %>/"
30       ClientApplication.all_permissions.each { |p| potlatch[p] = true }
31       potlatch.save!
32     end
33
34     if Kernel.const_defined?("Settings")
35       Settings.potlatch2_key = potlatch.key
36     else
37       POTLATCH2_KEY = potlatch.key
38     end
39
40     unless website = webmaster.client_applications.find_by_name("Web Site")
41       website = webmaster.client_applications.new
42       website.name = "Web Site"
43       website.url = "https://<%= @site %>/"
44       ClientApplication.all_permissions.each { |p| website[p] = true }
45       website.save!
46     end
47
48     if Kernel.const_defined?("Settings")
49       Settings.oauth_key = website.key
50     else
51       OAUTH_KEY = website.key
52     end
53   end
54
55   if ActiveRecord::Base.connection.table_exists?(:oauth_applications)
56     unless id = webmaster.oauth2_applications.find_by_name("iD")
57       id = webmaster.oauth2_applications.new
58       id.name = "iD"
59       id.redirect_uri = "https://<%= @site %>/id"
60       id.scopes = Oauth.scopes.map(&:name)
61       id.confidential = true
62       id.save!
63     end
64
65     if Kernel.const_defined?("Settings")
66       Settings.id_application = id.uid
67     else
68       ID_APPLICATION = id.uid
69     end
70
71     unless website = webmaster.oauth2_applications.find_by_name("Web Site")
72       website = webmaster.oauth2_applications.new
73       website.name = "Web Site"
74       website.redirect_uri = "https://<%= @site %>/"
75       website.scopes = Oauth.scopes.map(&:name)
76       website.confidential = true
77       website.save!
78     end
79
80     if Kernel.const_defined?("Settings")
81       Settings.oauth_application = website.uid
82     else
83       OAUTH_APPLICATION = website.uid
84     end
85   end
86 end