Class: ROM::LDAP::Directory::ENV Private

Inherits:
Object
  • Object
show all
Extended by:
Initializer
Defined in:
lib/rom/ldap/directory/env.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Parse uri and options received by the gateway configuration.

rubocop:disable Lint/UriEscapeUnescape

Examples:

scheme:// binddn : passwd @ host : port / base
ldap://uid=admin,ou=system:secret@localhost:1389/ou=users,dc=rom,dc=ldap

See Also:

Instance Method Summary collapse

Instance Method Details

#authHash, NilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Username and password.

Returns:

  • (Hash, NilClass)


66
67
68
# File 'lib/rom/ldap/directory/env.rb', line 66

def auth
  { username: bind_dn, password: bind_pw } if bind_dn
end

#baseString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Global search base. The value is derived in this order:

1. Gateway Options
2. ENVs
3. URI (unless this is a socket) defaults ""
4. an empty string

Examples:

'ldap://localhost/ou=users,dc=rom,dc=ldap' => ou=users,dc=rom,dc=ldap

Returns:

  • (String)


56
57
58
59
60
# File 'lib/rom/ldap/directory/env.rb', line 56

def base
  config.fetch(:base) do
    ::ENV['LDAPBASE'] || (path ? EMPTY_STRING : uri.dn.to_s)
  end
end

#inspectString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)


84
85
86
# File 'lib/rom/ldap/directory/env.rb', line 84

def inspect
  "<#{self.class.name} #{connection} />"
end

#sslHash, NilClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash, NilClass)


72
73
74
# File 'lib/rom/ldap/directory/env.rb', line 72

def ssl
  config[:ssl] if uri.scheme.eql?('ldaps')
end

#to_hHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)


78
79
80
# File 'lib/rom/ldap/directory/env.rb', line 78

def to_h
  { host: host, port: port, path: path, ssl: ssl, auth: auth }
end

#uriURI::LDAP, URI::LDAPS

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Build LDAP URL with encoded spaces.

Returns:

  • (URI::LDAP, URI::LDAPS)

Raises:

  • URI::InvalidURIError



41
42
43
# File 'lib/rom/ldap/directory/env.rb', line 41

def uri
  URI(connection.gsub(SPACE, PERCENT_SPACE))
end