Sha256: 4ebc8ee045f34eb09b8703ff16f9cae55244e2965ec8ae20bea56d1bb7b3fb53

Contents?: true

Size: 840 Bytes

Versions: 8

Compression:

Stored size: 840 Bytes

Contents

module Rails
  module Auth
    module X509
      # Matcher for making assertions about X.509 certificates
      class Matcher
        # @option options [String] cn Common Name of the subject
        # @option options [String] ou Organizational Unit of the subject
        def initialize(options)
          @options = options.freeze
        end

        # @param [Hash] env Rack environment
        def match(env)
          certificate = Rails::Auth.credentials(env)["x509"]
          return false unless certificate

          @options.all? { |name, value| certificate[name] == value }
        end

        # Generates inspectable attributes for debugging
        #
        # @return [Hash] hash containing parts of the certificate subject to match (cn, ou)
        def attributes
          @options
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rails-auth-2.1.4 lib/rails/auth/x509/matcher.rb
rails-auth-2.1.3 lib/rails/auth/x509/matcher.rb
rails-auth-2.1.2 lib/rails/auth/x509/matcher.rb
rails-auth-2.1.1 lib/rails/auth/x509/matcher.rb
rails-auth-2.1.0 lib/rails/auth/x509/matcher.rb
rails-auth-2.0.3 lib/rails/auth/x509/matcher.rb
rails-auth-2.0.2 lib/rails/auth/x509/matcher.rb
rails-auth-2.0.1 lib/rails/auth/x509/matcher.rb