Repository navigation
[master] rest_cherrypy: accept / force credentials via HTTP header - #66814
Malte-Wagner wants to merge 3 commits into
Conversation
|
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar. |
|
Hi @dwoz , is something still needed for this MR? Thanks |
twangboy
left a comment
There was a problem hiding this comment.
Also needs a changelog and some tests, please.
|
Thanks - i'll work on that. |
- Fix docstring bug: X-Forwarded-User listed twice instead of X-Forwarded-Password - Fix RST heading format (### is not valid RST; use underline style) - Fix typos: "diffent" -> "different", grammar in comment - Fix trailing whitespace in doc block - Fix indentation in _is_valid_token (2-space -> 4-space) - Fix inline comment spacing (PEP8: two spaces before #) - Fix missing blank line before force_header_creds() - Add changelog/66814.added.md - Add tests/pytests/unit/netapi/cherrypy/test_header_creds.py with 12 unit tests covering force_header_creds(), salt_auth_tool(), and Events._is_valid_token()
``_is_valid_token`` now reads ``cherrypy.request.headers`` to honor the X-Forwarded-User / X-Forwarded-Eauth header-credential feature. The pre-existing ``MockCherryPy`` shim in test_events.py lacked a ``request`` attribute, so both existing tests hit AttributeError. Add an empty ``request.headers`` dict to the shim; absent forwarded headers preserves the original "token only" semantics these tests exercise.
The acceptance of HTTP headers opens the possibility to either set or force credentials for a session.
A reverse proxy, can handle authentication and
inject the custom headers X-Forwarded-User, X-Forwarded-Password and/or X-Forwarded-Eauth. In general, these headers can work in conjunction with the eauth sharedsecret / rest / auto methods to externalize and flexibilize authentication, without raising code complexity for new or niche authentication methods inside salt.
What does this PR do?
This PR enables rest_cherrypy to gather credentials via HTTP headers, that may be set by reverse proxy, to use them for session creation or session checking.
What issues does this PR fix or reference?
#22046
Previous Behavior
Credentials are only allowed via request body.
New Behavior
Credentials are allowed via request body and http header.
Prevalence is http header over request body values.
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes
Please review Salt's Contributing Guide for best practices, including the
PR Guidelines.
See GitHub's page on GPG signing for more information about signing commits with GPG.