Skip to content
Snippets Groups Projects
Commit 835af1d6 authored by Ping Yu's avatar Ping Yu
Browse files

separate out the adaptor validation code, call the validation on

the request phase, since the adaptor now is only instantiated on
the callback phase.
parent 8b76e124
No related branches found
No related tags found
No related merge requests found
PATH
remote: .
specs:
omniauth-ldap (1.0.1)
omniauth-ldap (1.0.2)
net-ldap (~> 0.2.2)
omniauth (~> 1.0)
pyu-ruby-sasl (~> 0.0.3.1)
Loading
Loading
@@ -29,7 +29,7 @@ GEM
ruby_core_source (>= 0.1.4)
multi_json (1.0.3)
net-ldap (0.2.2)
omniauth (1.0.0)
omniauth (1.0.1)
hashie (~> 1.2)
rack
pyu-ruby-sasl (0.0.3.3)
Loading
Loading
Loading
Loading
@@ -26,18 +26,20 @@ module OmniAuth
 
attr_accessor :bind_dn, :password
attr_reader :connection, :uid, :base, :auth
def initialize(configuration={})
@configuration = configuration.dup
@configuration[:allow_anonymous] ||= false
@logger = @configuration.delete(:logger)
def self.validate(configuration={})
message = []
MUST_HAVE_KEYS.each do |name|
message << name if configuration[name].nil?
message << name if configuration[name].nil?
end
raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
end
def initialize(configuration={})
Adaptor.validate(configuration)
@configuration = configuration.dup
@configuration[:allow_anonymous] ||= false
@logger = @configuration.delete(:logger)
VALID_ADAPTER_CONFIGURATION_KEYS.each do |name|
instance_variable_set("@#{name}", configuration[name])
instance_variable_set("@#{name}", @configuration[name])
end
method = ensure_method(@method)
config = {
Loading
Loading
Loading
Loading
@@ -27,6 +27,7 @@ module OmniAuth
option :name_proc, lambda {|n| n}
 
def request_phase
OmniAuth::LDAP::Adaptor.validate @options
f = OmniAuth::Form.new(:title => (options[:title] || "LDAP Authentication"), :url => callback_path)
f.text_field 'Login', 'username'
f.password_field 'Password', 'password'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment