13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/end_point_blank/commands/basic_authenticate.rb', line 13
def authenticate(request)
client_auth = request.['Authorization']
auth = "Basic #{AuthorizationGenerate.generate}"
body = {
path: request.route_uri_pattern.to_s.gsub(/\([^)]*\)/, ''),
http_method: request.request_method,
client_auth: client_auth,
application: Configuration.instance.app_name,
endpoint_version: VersionFinder.new.find(request),
ip_address: request.remote_ip
}
response = Http.post(configuration.authorize_url, auth, body)
return nil if response.nil?
EndPointBlank.logger.info "Authentication response: #{response.status} - #{response.body}"
if response.status > 299
EndPointBlank.logger.error "Failed to authenticate: #{response.status} - #{response.body}"
end
response
end
|