Sha256: 5c8b0d3da42950332ea43aae72e2e80539c6edd87f4ac4aec15bc279011cfa28

Contents?: true

Size: 628 Bytes

Versions: 7

Compression:

Stored size: 628 Bytes

Contents

module Ddr::Auth
  class WebAuthContext < AuthContext

    # @return [String] the IP address, or nil
    # @see ActionDispatch::RemoteIp
    def ip_address
      if middleware = env["action_dispatch.remote_ip"]
        middleware.calculate_ip
      end
    end

    # @return [Array<String>]
    def affiliation
      anonymous? ? super : split_env("affiliation").map { |a| a.sub(/@duke\.edu\z/, "") }
    end

    # @return [Array<String>]
    def ismemberof
      anonymous? ? super : split_env("ismemberof")
    end

    private

    def split_env(attr, delim = ";")
      env.fetch(attr, "").split(delim)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ddr-models-3.0.8 lib/ddr/auth/web_auth_context.rb
ddr-models-3.0.7 lib/ddr/auth/web_auth_context.rb
ddr-models-3.0.6 lib/ddr/auth/web_auth_context.rb
ddr-models-3.0.5 lib/ddr/auth/web_auth_context.rb
ddr-models-3.0.4 lib/ddr/auth/web_auth_context.rb
ddr-models-3.0.3 lib/ddr/auth/web_auth_context.rb
ddr-models-3.0.2 lib/ddr/auth/web_auth_context.rb