-
Notifications
You must be signed in to change notification settings - Fork 274
Add impersonate User feature #7988
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
Open
mpmadhavig
wants to merge
11
commits into
wso2:master
Choose a base branch
from
mpmadhavig:impersonat-button
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5922fca
Add i18n templates.
mpmadhavig 7211d85
Add util function to generate pkce challange and verifier.
mpmadhavig f118356
Modifiy danger zone components to add a non danger component.
mpmadhavig 97a138a
Add impersonate user button and functionality.
mpmadhavig cfe669e
Add license header.
mpmadhavig c0fe3f7
Make my account impersonate role uneditable.
mpmadhavig 1b85128
Separate out impersonation action.
mpmadhavig 2b3572f
Remove impersonate role edit priviledges.
mpmadhavig 82d4ff5
Address PR comments.
mpmadhavig d329c55
Show only Applications section when myaccount impersonation.
mpmadhavig 15c7784
Refactor.
mpmadhavig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
apps/console/src/public/resources/users/init-impersonate.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<!-- | ||
~ Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). | ||
~ | ||
~ WSO2 LLC. licenses this file to you under the Apache License, | ||
~ Version 2.0 (the "License"); you may not use this file except | ||
~ in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, | ||
~ software distributed under the License is distributed on an | ||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
~ KIND, either express or implied. See the License for the | ||
~ specific language governing permissions and limitations | ||
~ under the License. | ||
--> | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
<body onload="authenticate()"> | ||
<script> | ||
var hash = window.location.hash; | ||
function authenticate() { | ||
if (!hash) { | ||
if (window.location.href.includes("oauth2_error.do")) { | ||
if (sessionStorage.getItem("impersonation_artifacts") === null) { | ||
sessionStorage.setItem("impersonation_artifacts", "oauth2_error"); | ||
} | ||
window.parent.postMessage("impersonation-authorize-request-complete", "*"); | ||
} else { | ||
const params = new URLSearchParams(window.location.search); | ||
const userId = params.get("userId"); | ||
const code_challenge = params.get("codeChallenge"); | ||
const client_id = params.get("clientId"); | ||
const authorization_endpoint = sessionStorage.getItem("authorization_endpoint"); | ||
window.location.href = authorization_endpoint | ||
+ "?client_id=" + client_id + | ||
"&redirect_uri=" + window.location.origin + window.location.pathname + | ||
"&state=sample_state&scope=internal_user_impersonate&response_type=id_token%20subject_token" + | ||
"&requested_subject=" + userId + | ||
"&nonce=" + getNonce() + "&code_challenge=" + code_challenge + "&code_challenge_method=S256"; | ||
} | ||
} else { | ||
if (sessionStorage.getItem("impersonation_artifacts") === null) { | ||
sessionStorage.setItem("impersonation_artifacts", hash); | ||
} | ||
window.parent.postMessage("impersonation-authorize-request-complete", "*"); | ||
} | ||
} | ||
|
||
function getNonce() { | ||
return Math.floor(Math.random() * (10000000 - 1000000 + 1)) + 1000000; | ||
} | ||
|
||
</script> | ||
</body> | ||
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
instead of comparing the display name, shall we use
role.meta.systemRole
property? (I'm assuming the myaccount impersonation role is a system role. correct me if im wrong)