PKI external_auth
What would a PKI external_auth look like? Would you pass it a DN from a user's cert? The email address? What configs would it need?
I'm thinking more of how a PKI login would work for Halite (from https://github.com/saltstack/halite/issues/48) than managing user permissions for issuing the salt command. This would make Halite implementation for large enterprises running their own PKI ecosystem much easier.
What this would look like is that the auth function in the external auth module would PROBABLY accept the user certificate as an argument (passed in as a string). Then the auth system would validate said cert. Is this what you are asking?
This is exactly what I'm asking. Thanks. I'll try do to some more digging around when I get the chance to see how, exactly, the auth function would work.
Thanks!
Thanks! I think this would be a great thing to have in eauth!
I vaguely remember hearing that Salt is trying to move away from one of the Python crypto libraries. If this is true, which one is it, so I don't create another dependency on it?
M2Crypto is the one we're trying to deprecate. If you need a crypto library, please use PyCrypto. Though in any case it will be an optional dependency.
Noted. Thanks!
I have a first cut here.
This version takes in a pem-encoded user cert and a CA cert. Returns True if the CA signed the user cert; False otherwise. The final version would pull the CA cert from a location specified by the master config.
Thoughts? Is this the direction you see this going? I'll work on pulling the CA cert from a specified location next.
I've updated the gist (link) to where the module pulls the CA cert from a file specified in the Master config. I'm currently learning the Salt testing ecosystem so I can give it a proper test.
I'm very interested in this.
Have you tested it on the latest version? I can't get it work...
@kottenator Can you describe how you're testing it and what you're seeing?
I configure pki auth in master config:
external_auth:
pki:
ca_file: /path/to/root-ca.pem
Then I try to execute:
salt -a pki --pem="`cat user.crt`" '*' test.ping
It gives an error: no such option: --pem
How can I pass the certificate?
@kottenator Salt may not be recognizing the 'pki' eauth option. I'm seeing this in the man page:
-a EAUTH, --auth=EAUTH
Pass in an external authentication medium to validate against. The credentials will be prompted for. The options are auto, keystone, ldap, pam, and stormpath. Can be used with the -T option.
I'd have to dig into the code to confirm this suspicion though.
Yes, it prompts to enter "pem" if it's not passed. But I want to automate it so prompt is not an option, I guess
Oh. Well that's interesting. I wonder if something has to be done to the pki_auth module in order to expose those options...
Another problem is: even if I pass the certificate contents into the prompt, it still doesn't work. The pki.auth function doesn't fire at all.
I took a look into salt auth: it considers the first param of the pki.auth as the username and tries to find it in ACL for selected eauth... but it's the CRT contents, not the username, so salt doesn't find such user and thus it doesn't trigger the pki.auth function.
To make it work, it should be def auth(username, pem, **kwargs): (even if you don't do anything with username) and you should specify ACL for the user in master config:
external_auth:
pki:
ca_file: /path/to/root-ca.pem
user:
- .*
Then you need to run:
salt -a pki --username=user '*' test.ping
pem: CRT CONTENTS
And then it would trigger the pki.auth function. And I still need to get rid of the prompt :)
Here is my pull-request. I haven't found a better way to make it work with CLI/API other than to use username and password keywords:
usernameis required in any case. Without itpki.auth(...)function will not be triggered at allpasswordis only for CLI usage (we can passpemto API but not to CLI)
Please, improve it if possible
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.