Sha256: da722f4f11283a6a0ef6f0147bc57fd2ca2f28e80ae82f9b146cca500a6f26df

Contents?: true

Size: 586 Bytes

Versions: 112

Compression:

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

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

    private

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

  end
end

Version data entries

112 entries across 112 versions & 2 rubygems

Version Path
ddr-core-0.2.2 lib/ddr/auth/web_auth_context.rb
ddr-core-0.2.1 lib/ddr/auth/web_auth_context.rb
ddr-models-2.11.0 lib/ddr/auth/web_auth_context.rb
ddr-models-2.10.2 lib/ddr/auth/web_auth_context.rb
ddr-models-2.10.1 lib/ddr/auth/web_auth_context.rb
ddr-models-2.10.0 lib/ddr/auth/web_auth_context.rb
ddr-models-2.10.0.rc2 lib/ddr/auth/web_auth_context.rb
ddr-models-2.10.0.rc1 lib/ddr/auth/web_auth_context.rb
ddr-models-2.9.2 lib/ddr/auth/web_auth_context.rb
ddr-models-2.9.1 lib/ddr/auth/web_auth_context.rb
ddr-models-2.9.0 lib/ddr/auth/web_auth_context.rb
ddr-models-2.9.0.rc1 lib/ddr/auth/web_auth_context.rb
ddr-models-2.8.0 lib/ddr/auth/web_auth_context.rb
ddr-models-2.8.0.rc1 lib/ddr/auth/web_auth_context.rb
ddr-models-2.7.6 lib/ddr/auth/web_auth_context.rb
ddr-models-2.7.5 lib/ddr/auth/web_auth_context.rb
ddr-models-2.7.4 lib/ddr/auth/web_auth_context.rb
ddr-models-2.7.3 lib/ddr/auth/web_auth_context.rb
ddr-models-2.7.2 lib/ddr/auth/web_auth_context.rb
ddr-models-2.7.1 lib/ddr/auth/web_auth_context.rb