Manage groups of remote user based on header #5060
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do and why is it necessary?
This extends the existing functionality to automatically manage the users based on headers provided by an auth proxy in front of OctoPrint to include group management. This allows one to use an external source of users with varying levels of access.
By configuring a header that contains a comma-separated list of groups and optionally a mapping of the names in this list to the names of the matching OctoPrint groups (in case these don't match) this will manage the list of groups that a user belongs to.
How was it tested? How can it be tested by the reviewer?
I've mostly tested this by configuring it to look at the groups header that OAuth2 Proxy sends. (Note that it doesn't include this header by default, the
--set-xauthrequest
flag enables this.) It can also be tested by simply including these headers in a manual request.Example configuration:
This can be tested by performing a login request with e.g. curl:
In the output of this request it can be observed that the user is in the
readonly
andusers
groups. (Most fields have been omitted from this output for the sake of brevity.)Repeating the request with one of the groups removed will result in the user also losing said group:
Any background context you want to provide?
No.
What are the relevant tickets if any?
None that I am aware of.
Screenshots (if appropriate)
N/A.
Further notes
N/A.