Class: OmniAuth::LDAP::Adaptor

Inherits:
Object
  • Object
show all
Defined in:
lib/contour/fixes/omniauth.rb

Defined Under Namespace

Classes: AuthenticationError, ConfigurationError, ConnectionError, LdapError

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#authObject (readonly)

Returns the value of attribute auth.



56
57
58
# File 'lib/contour/fixes/omniauth.rb', line 56

def auth
  @auth
end

#baseObject (readonly)

Returns the value of attribute base.



56
57
58
# File 'lib/contour/fixes/omniauth.rb', line 56

def base
  @base
end

#bind_dnObject

Returns the value of attribute bind_dn.



55
56
57
# File 'lib/contour/fixes/omniauth.rb', line 55

def bind_dn
  @bind_dn
end

#connectionObject (readonly)

Returns the value of attribute connection.



56
57
58
# File 'lib/contour/fixes/omniauth.rb', line 56

def connection
  @connection
end

#passwordObject

Returns the value of attribute password.



55
56
57
# File 'lib/contour/fixes/omniauth.rb', line 55

def password
  @password
end

#uidObject (readonly)

Returns the value of attribute uid.



56
57
58
# File 'lib/contour/fixes/omniauth.rb', line 56

def uid
  @uid
end

Class Method Details

.validate(configuration = {}) ⇒ Object

Raises:

  • (ArgumentError)


57
58
59
60
61
62
63
# File 'lib/contour/fixes/omniauth.rb', line 57

def self.validate(configuration={})
  message = []
  MUST_HAVE_KEYS.each do |name|
     message << name if configuration[name].nil?
  end
  raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
end

Instance Method Details

#bind_as(args = {}) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/contour/fixes/omniauth.rb', line 65

def bind_as(args = {})
  result = false
  ldap = @connection
  ldap.auth args[:username], args[:password]
  rs = ldap.search(base: args[:base], filter: Net::LDAP::Filter.eq(@uid, args[:username].split('\\').last.to_s))
  result = rs.first if rs
  result
end