Sha256: 9bcc80b637413bd5268189152ca9828b98e491b8234b4453c140c75769b31439

Contents?: true

Size: 711 Bytes

Versions: 35

Compression:

Stored size: 711 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
      if anonymous?
        super
      else
        split_env("affiliation").map { |a| a.sub(/@duke\.edu\z/, "") }
      end
    end

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

    private

    def split_env(attr, delim = ";")
      val = env[attr] || env["HTTP_#{attr.upcase}"]
      val ? val.split(delim) : []
    end

  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
ddr-core-1.17.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.16.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.15.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.14.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.13.2 lib/ddr/auth/web_auth_context.rb
ddr-core-1.13.1 lib/ddr/auth/web_auth_context.rb
ddr-core-1.13.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.12.2 lib/ddr/auth/web_auth_context.rb
ddr-core-1.12.1 lib/ddr/auth/web_auth_context.rb
ddr-core-1.12.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.11.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.10.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.9.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.8.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.7.0 lib/ddr/auth/web_auth_context.rb
ddr-core-1.6.6 lib/ddr/auth/web_auth_context.rb
ddr-core-1.6.5 lib/ddr/auth/web_auth_context.rb
ddr-core-1.6.4 lib/ddr/auth/web_auth_context.rb
ddr-core-1.6.3 lib/ddr/auth/web_auth_context.rb
ddr-core-1.6.2 lib/ddr/auth/web_auth_context.rb