Class: Ddr::Auth::WebAuthContext

Inherits:
AuthContext show all
Defined in:
lib/ddr/auth/web_auth_context.rb

Instance Attribute Summary

Attributes inherited from AuthContext

#env, #user

Instance Method Summary collapse

Methods inherited from AuthContext

#agent, #agents, #anonymous?, #authenticated?, #authorized_to_act_as_superuser?, #duke_agent?, #groups, #initialize, #member_of?, #superuser?

Constructor Details

This class inherits a constructor from Ddr::Auth::AuthContext

Instance Method Details

#affiliationArray<String>

Returns:

  • (Array<String>)


13
14
15
# File 'lib/ddr/auth/web_auth_context.rb', line 13

def affiliation
  anonymous? ? super : split_env("affiliation").map { |a| a.sub(/@duke\.edu\z/, "") }
end

#ip_addressString

Returns the IP address, or nil.

Returns:

  • (String)

    the IP address, or nil

See Also:

  • ActionDispatch::RemoteIp


6
7
8
9
10
# File 'lib/ddr/auth/web_auth_context.rb', line 6

def ip_address
  if middleware = env["action_dispatch.remote_ip"]
    middleware.calculate_ip
  end
end

#ismemberofArray<String>

Returns:

  • (Array<String>)


18
19
20
# File 'lib/ddr/auth/web_auth_context.rb', line 18

def ismemberof
  anonymous? ? super : split_env("ismemberof")
end