The upcoming release of Salt 0.10.4 contains support for external authentication mechanisms. As well as restricting who can run what and on what servers, this new feature allows the handing-off of authentication to a 3rd party module.
This post describes how to setup and use an LDAP external authentication module for Salt.
Download the auth/ldap.py module from my GitHub repo and place it in the corresponding directory of your salt root (so salt/auth/ldap.py).
Update your salt master config file to activate external authentication and set some basic ACLs:
external_auth: ldap: kris@acme.com: - 'saltdev': - test.*
The configuration above should restrict the salt user ‘kris@acme.com’ such that he can run the ‘test’ module methods on the minion ‘saltdev’ if he successfully authenticates to LDAP.
Before this will work, however, we need to configure the LDAP connection information, also in the master config file. This is used to make the initial LDAP bind when searching for the user dn.
As a minimum you will need:
auth.ldap.basedn: auth.ldap.binddn: auth.ldap.bindpw: auth.ldap.filter: - (also see below)
NB auth.ldap.filter represents the LDAP search filter used to find the dn associated with the salt user. It can (and normally should) contain the special string:
{{ username }}
This string (including the braces) will be substituted for the value of the username supplied by the user as part of authentication. For example the string:
auth.ldap.filter: emailAddress={{ username }}
becomes:
auth.ldap.filter: emailAddress=kris@acme.com
when a user supplies the username ‘kris@acme.com’ during authentication.
In addition, the following configuration items are as permitted:
auth.ldap.server: - default: localhost auth.ldap.port: - default: 389 auth.ldap.tls: - default: False auth.ldap.scope: - default: 2 (sub)
The salt command using external authentication looks like the following:
salt -a ldap 'saltdev' test.ping username: kris@acme.com password: saltdev: True
A failed authentication attempt looks like the following:
salt -a ldap 'saltdev' test.ping username: bob@acme.com password: Failed to authenticate, is this user permitted to execute commands?
To create a token which will elimiate the need to reauthenticate for a certain period (default is 12 hrs), run the same command with the -T option:
salt -T -a ldap 'saltdev' test.ping username: kris@acme.com password: saltdev: True
This will create a token file called .salt_token in the user’s home directory containing the token value:
cat ~/.salt_token 02b6c56c964409c61e6806a2db2dd2e4
From this point, until the token expires, you no longer need to supply any authentication options:
salt 'saltdev' test.ping saltdev: True
If you do run the command with the -a option, salt will ignore whatever you supply and use the token:
salt -a ldap 'saltdev' test.ping username: foo password: bar saltdev: True
If you run the salt command again with the -T option, your token will be reset:
salt -T -a ldap 'saltdev' test.ping username: kris@acme.com password: saltdev: True cat /Users/kris/.salt_token d77127794fdc7d69a9a56d
There is an implicit ‘deny all’ when you activate external authentication so only users specified in the master config will be able to access salt commands.
External authentication also supplants any client_acls specified so there should be no need to use to the two together.
We work with our clients to de-risk and accelerate their business goals realisation. Our approach is based on tailoring our services to fit your needs leveraging our portfolio of strategy, execution, innovation and service delivery offerings to help you reach your objectives
We’re always on the lookout for exceptional talent and people who share our values. Even as we continue to grow, we maintain a family environment with respect and teamwork core to our culture.
Companies can start deploying containerised workloads to Kubernetes In days not months, by leveraging Automation Logic’s Kubernetes Platform Accelerator.
Largest Irish-Founded Tech Employer Surpasses 3000 Employees Signing 15th and 16th Acquisition Deals Version 1, a leading digital transformation partner, is to acquire Automation Logic – for an undisclosed sum as part of its ambitious growth strategy for 2023 and beyond. The Automation Logic deal is subject to clearance by the National Security and Investment […]
Automation Logic were recognised as one of the UK’s best Workplaces again for the 5th year running! We also placed 29th in best workplaces for women. This highlights the great work that we are doing as a business, including all the wonderful work being put in by the employee-led DE&I groups. This award means so […]