Sha256: 890bcdfbd4a10db5ccfc877dfe87815d9a7ccd0b8937ad1ff13cbcf1bb78327c

Contents?: true

Size: 850 Bytes

Versions: 10

Compression:

Stored size: 850 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.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

10 entries across 10 versions & 1 rubygems

Version Path
rails-auth-1.3.0 lib/rails/auth/x509/matcher.rb
rails-auth-1.2.0 lib/rails/auth/x509/matcher.rb
rails-auth-1.1.0 lib/rails/auth/x509/matcher.rb
rails-auth-1.0.0 lib/rails/auth/x509/matcher.rb
rails-auth-0.5.3 lib/rails/auth/x509/matcher.rb
rails-auth-0.5.2 lib/rails/auth/x509/matcher.rb
rails-auth-0.5.1 lib/rails/auth/x509/matcher.rb
rails-auth-0.5.0 lib/rails/auth/x509/matcher.rb
rails-auth-0.4.1 lib/rails/auth/x509/matcher.rb
rails-auth-0.4.0 lib/rails/auth/x509/matcher.rb