Skip to content

Commit

Permalink
Add ldap auth + mount_point example
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffrey Hogan committed Jul 17, 2018
1 parent c6f4718 commit 9725caf
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion docs/examples/ldap_auth_method.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,34 @@ LDAP Auth Backend
Authentication
--------------

Generic authentication with an LDAP username and password:

.. code:: python
# LDAP, Username & Password
client.auth_ldap('MY_USERNAME', 'MY_PASSWORD')
client.auth_userpass('MY_USERNAME', 'MY_PASSWORD')
Using a custom mount_point:


.. code:: python
# For a LDAP backend mounted under a non-default (ldap) path.
# E.g., via Vault CLI with `vault auth enable -path=prod-ldap ldap`
from getpass import getpass
import hvac
service_account_username = 'someuser'
password_prompt = 'Please enter your password for the LDAP authentication backend: '
service_account_password = getpass(prompt=password_prompt)
client = hvac.Client()
# Here the mount_point parameter corresponds to the path provided when enabling the backend
client.auth_ldap(
username=service_account_username,
password=service_account_password,
mount_point='prod-ldap'
)
print(client.is_authenticated) # => True

0 comments on commit 9725caf

Please sign in to comment.