- # extract authorisation credentials from headers, returns user = nil if none
- def get_auth_data
- if request.env.has_key? 'X-HTTP_AUTHORIZATION' # where mod_rewrite might have put it
- authdata = request.env['X-HTTP_AUTHORIZATION'].to_s.split
- elsif request.env.has_key? 'REDIRECT_X_HTTP_AUTHORIZATION' # mod_fcgi
- authdata = request.env['REDIRECT_X_HTTP_AUTHORIZATION'].to_s.split
- elsif request.env.has_key? 'HTTP_AUTHORIZATION' # regular location
- authdata = request.env['HTTP_AUTHORIZATION'].to_s.split
- end
- # only basic authentication supported
- if authdata and authdata[0] == 'Basic'
- user, pass = Base64.decode64(authdata[1]).split(':',2)
- end
- return [user, pass]
- end
+ ##
+ # Unfortunately if a PUT or POST request that has a body fails to
+ # read it then Apache will sometimes fail to return the response it
+ # is given to the client properly, instead erroring:
+ #
+ # https://issues.apache.org/bugzilla/show_bug.cgi?id=44782
+ #
+ # To work round this we call rewind on the body here, which is added
+ # as a filter, to force it to be fetched from Apache into a file.
+ def fetch_body
+ request.body.rewind
+ end
+
+ def map_layout
+ append_content_security_policy_directives(
+ :child_src => %w[127.0.0.1:8111],
+ :connect_src => %w[nominatim.openstreetmap.org overpass-api.de router.project-osrm.org],
+ :form_action => %w[render.openstreetmap.org],
+ :script_src => %w[graphhopper.com open.mapquestapi.com],
+ :img_src => %w[developer.mapquest.com]
+ )
+
+ if STATUS == :database_offline || STATUS == :api_offline
+ flash.now[:warning] = t("layouts.osm_offline")
+ elsif STATUS == :database_readonly || STATUS == :api_readonly
+ flash.now[:warning] = t("layouts.osm_read_only")
+ end