Secure communication with LDAP server
defmodule MyApp.Insecure do
@username 'username'
@password 'password'
def authenticate do
:eldap.open(['ldap://example.com'])
|> :eldap.simple_bind({@username, @password})
end
end
In this insecure code example, we're connecting to an LDAP server without any encryption. The password is sent in plaintext over the network. An attacker who can listen to the network traffic can intercept the password.
defmodule MyApp.Secure do
@username 'username'
@password 'password'
def authenticate do
:eldap.open(['ldaps://example.com'])
|> :eldap.simple_bind({@username, @password})
end
end
In this secure code example, we're connecting to the LDAP server over SSL. The network traffic, including the password, is encrypted. This prevents attackers from intercepting the password.