Class: Keycard::Request::ProxiedAttributes

Inherits:
Attributes
  • Object
show all
Defined in:
lib/keycard/request/proxied_attributes.rb

Overview

This request wrapper should be used when the application will be served behind a reverse proxy. It relies on the trusted relationship with the proxy to use HTTP headers for forwarded values.

The typical headers forwarded are X-Forwarded-User and X-Forwarded-For, which, somewhat confusingly, are transposed into HTTP_X_REMOTE_USER and HTTP_X_FORWARDED_FOR once the Rack request is assembled.

Constant Summary

Constants inherited from Attributes

Attributes::IDENTITY_ATTRS

Instance Method Summary collapse

Methods inherited from Attributes

#[], #all, #auth_token, #base, #external, #identity, #identity_keys, #initialize, #supplemental

Constructor Details

This class inherits a constructor from Keycard::Request::Attributes

Instance Method Details

#client_ipObject



20
21
22
# File 'lib/keycard/request/proxied_attributes.rb', line 20

def client_ip
  safe('HTTP_X_FORWARDED_FOR').split(',').first
end

#user_eidObject



16
17
18
# File 'lib/keycard/request/proxied_attributes.rb', line 16

def user_eid
  user_pid
end

#user_pidObject



12
13
14
# File 'lib/keycard/request/proxied_attributes.rb', line 12

def user_pid
  get 'HTTP_X_REMOTE_USER'
end