Sha256: d3cc67bd26bf8a059a19d37fdc48ca39ccf923f2e1055c0d95c89d36c5f3ad28

Contents?: true

Size: 629 Bytes

Versions: 3

Compression:

Stored size: 629 Bytes

Contents

module Rails
  module Auth
    module X509
      # Predicate 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
        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
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-auth-0.3.0 lib/rails/auth/x509/matcher.rb
rails-auth-0.2.0 lib/rails/auth/x509/matcher.rb
rails-auth-0.1.0 lib/rails/auth/x509/matcher.rb