Adding client_acl functionality to rest_cherrypy API.#25632
Adding client_acl functionality to rest_cherrypy API.#25632cachedout merged 19 commits intosaltstack:developfrom TheScriptSage:develop
Conversation
…low certain users to access the API from certain hosts only.
There was a problem hiding this comment.
this needs to be .. versionadded:: Boron.
|
Thanks, @TheScriptSage. |
|
I put the code in the wrong spot for my pull request, so I've fixed it. Additionally I've fixed the version added. Sorry about that, thanks for picking it up. |
|
I'm not sure we want to call it |
|
@jacksontj - I believe since the options are specific to the rest_cherrypy (inside of the configuration for it), I think the name is OK inside of the rest_cherrypy section, and it lets people know it's similar to the old one. I can change it to something like "api_acl" if needed. As for the groups, no, right now it just checks the user, I'm going to look into the groups as well but for now this works for users (which is needed for the business need we have). If I have some more time I'll look into adding group support but I have this tested and working for users. As for the actual tests, I'll look into those as well but I'm not entirely familiar with salt's testing so I suspect that would take longer. Thanks for the feedback. |
|
Talked to @jacksontj in person, will rename it once the tests have all passed and I know that I don't have any more problems. |
|
@jfindlay - I am not sure what to do about this. This looks like an ubuntu test and I don't have any way to really test it. My assumption is that this is related to the if statement where it assigns creds and it's likely that it's picking up a dict that doesn't have username, can you provide some insight here? Thanks. |
|
@jfindlay - Nevermind, I see what the problem is. The creds dict being passed for the test doesn't have a valid username key. I'll wrap the username assignment with .get(). |
|
I think these test failures are unrelated, I'll make my change for it to be "api_acl" either tonight or tomorrow and then update this again. Thanks. |
|
@TheScriptSage, yes those test failures are unrelated. @jacksontj, these test tcp transport unit test failures have been happening consistently on the CentOS 7 pull requests. I looked at them a little today but am unsure what to do. Do you have any ideas? Thanks. |
|
@jfindlay I noticed that too-- although I can't reproduce it locally at all. Can we spin a VM or something that can repro the issue? |
|
@jacksontj, I'll try to do that, thanks. |
|
@jfindlay - I put in my changes from client_acl to api_acl, but the tests are still failing, this one isn't from me either (out of memory, etc). Do you want to still merge this in? Also I don't know the oldest tag to apply this to, so if you have any tips on how to figure that out that would be great. Thanks! |
|
@jfindlay - I've updated this pull request again to check if the request is being proxied as well, which should help when people want to go through a main proxy but still only be allowed from certain hosts. Once these tests pass/fail I think that's all from me for this pull request. Thanks. |
|
@TheScriptSage, if there are any test failures, I should be able to know if they are unrelated. Thanks for your work. |
|
I think there might be something wrong with some jenkins nodes or something those errors are odd. Anyway, I'll leave this to you. Thanks again. |
There was a problem hiding this comment.
Using the X-Forwarded-For header has a couple problems:
- First off, its not a single ip-- its the chain of proxies and the client for this request (https://en.wikipedia.org/wiki/X-Forwarded-For)
- Second off, this header can't really be trusted... since its just a header (meaning anyone can set it to whatever they want).
I'd suggest not supporting proxies, unless its needed as it can be a bit difficult on the API side to determine what the actual client is. If support is needed, then it should be configurable (on/off-- and ideally to let the user pick a header-- since its common for people's setups to have a specific header which is sanitized).
There was a problem hiding this comment.
I'll add a configuration for it. Good idea. Will get another commit up sometime tonight or tomorrow.
There was a problem hiding this comment.
I'm still working on this, my weekend got away from me and I'll update this shortly. Thanks.
|
I'll change it to fail closed due to the '*' stuff I added. Good point. As for the group stuff, the groups would be harder since I'd have to process their request, pass their request to their eauth of choice (and make sure it has a groups() function), and then parse that. Not sure if that would fit well here, but I can look into it. Thanks for the feedback. Will get to work on this shortly. |
… stops throwing an exception.
|
So, I've been thinking about this, and after consulting with some other folks internally, I'm going to scratch the proxy stuff entirely. It's too insecure and I can't think of a fast and efficient way to do this. So, for now I'm going to make sure it passes for just doing IP whitelisting for users that are trying to auth through the API. Added some sphinx docs and stuff as well so that things are more 'clean'. Will watch for the results. Thanks for the back and forth @jacksontj, @jfindlay. |
|
@jfindlay Is there an easy way to kick off the tests again? I don't think I am responsible for these failures. I can always push an empty commit, not sure if there's another option. Thanks. |
|
Pushed an empty commit and still saw the same error. Gonna leave this for you guys to look at, since I'm not sure this is me. Thanks. 22:18:02 * DEBUG: Installed git version: 1.9.1 |
|
Oh, looks like the tests finally went further, I see the same problem that I had fixed before and accidentally reverted out, I'll get it fixed again. Thanks for looking at the tests if someone did. |
|
Hey again, I think this failure isn't related to me. Mind looking? @jfindlay |
|
@TheScriptSage, yes, that is unrelated. |
Adding client_acl functionality to rest_cherrypy API.
|
Finally got this one in. :] Thanks for your patience @TheScriptSage |
Hey Saltstack folks!
We have a business need for allowing certain users to access the API from certain hosts. Because of this the normal whitelist IP wouldn't work, so I stole the idea from master and made a client_acl inside of the rest_cherrypy configuration. It looks similar to the other one as well:
This has been tested and working using the following inputs:
All seem to work. This also should work without the value being there, so nobody who is using the API should have to change anything, it's just a new feature they can get.
If there's a better place to put this, please let me know, but this was pretty easy to implement here.
Thanks.