]> git.openstreetmap.org Git - chef.git/blobdiff - cookbooks/overpass/templates/default/apache.erb
Limit TOTP controls to the query-features endpoint
[chef.git] / cookbooks / overpass / templates / default / apache.erb
index fbf82cf0479fe66d2a142c9aa726294974770206..8ccd28a9d3eae34cfe2e2eabcca8614a03073144 100644 (file)
 
         DocumentRoot <%= @directory %>
 
 
         DocumentRoot <%= @directory %>
 
+        RewriteEngine on
+        RewriteMap totp prg:/srv/query.openstreetmap.org/apache/totp-filter
+        RewriteCond ${totp:%{HTTP_COOKIE}} =0
+        RewriteRule ^/query-features - [F,L]
+
 <% if node[:overpass][:restricted_api] -%>
         ScriptAlias /query-features <%= @script_directory %>/interpreter
         SetEnvIf Origin "http.*(osm.org|openstreetmap.org).*" AccessControlAllowOrigin=$0
         # Remove Origin so Overpass does not interfere.
         RequestHeader unset Origin
         Header always add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
 <% if node[:overpass][:restricted_api] -%>
         ScriptAlias /query-features <%= @script_directory %>/interpreter
         SetEnvIf Origin "http.*(osm.org|openstreetmap.org).*" AccessControlAllowOrigin=$0
         # Remove Origin so Overpass does not interfere.
         RequestHeader unset Origin
         Header always add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
+        Header always add Access-Control-Allow-Credentials true
 <% else -%>
         ScriptAlias /api/ <%= @script_directory %>/
 <% end -%>
 <% else -%>
         ScriptAlias /api/ <%= @script_directory %>/
 <% end -%>