-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Allow replacement string to substitute against original user in impersonation #14962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3997a6b
d8cca99
dbc6cd0
12e38f4
870f2ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -544,7 +544,9 @@ Each impersonation rule is composed of the following fields: | |
| * ``original_role`` (optional): regex to match against role names of the | ||
| requesting impersonation. Defaults to ``.*``. | ||
| * ``new_user`` (required): regex to match against the user that will be | ||
| impersonated. | ||
| impersonated. May contain references to subsequences captured during the match | ||
| against *original_user*, and each reference will be replaced by the result of | ||
| evaluating the corresponding group respectively. | ||
| * ``allow`` (optional): boolean indicating if the authentication should be | ||
| allowed. Defaults to ``true``. | ||
|
|
||
|
|
@@ -553,7 +555,9 @@ The impersonation rules are a bit different than the other rules: The attribute | |
| Doing so it was possible to make the attribute ``allow`` optional. | ||
|
|
||
| The following example allows the ``admin`` role, to impersonate any user, except | ||
| for ``bob``. It also allows any user to impersonate the ``test`` user: | ||
| for ``bob``. It also allows any user to impersonate the ``test`` user. It also | ||
|
||
| allows a user in the form ``team_backend`` to impersonate the | ||
| ``team_backend_sandbox`` user, but not arbitrary users: | ||
|
|
||
| .. literalinclude:: user-impersonation.json | ||
| :language: json | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide tests where number of groups is incorrect. For example:
and
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1st example: done.
2nd example: done. please note that
new_useris required, even though it can be explicitly set to.*. This likely is to force the user to explicitly spell out match-all, if that's their intention, whereas allowing it optional and defaulting to match-all might result in unintentional global match, causing security risks. Therefore, I have slightly modified your example, by settingnew_userto.*explicitly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also in order to avoid interfering with other tests, I've used new prefixes
abc_anddef_respectively.