Skip to content
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

skip showing allowed scopes #5012

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-ducks-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@wso2is/identity-apps-core": patch
---

Skip showing consent for random scopes
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,31 @@
requestedOIDCScopeString = URLDecoder.decode(queryParamMap.get("requested_oidc_scopes"), "UTF-8");
}

String consentSkipScopesString = "";
if (queryParamMap.containsKey("consent_skip_scopes")) {
consentSkipScopesString = URLDecoder.decode(queryParamMap.get("consent_skip_scopes"), "UTF-8");
}
// Initialize empty arrays for safety.
String[] scopesArray = StringUtils.isNotBlank(scopeString) ? scopeString.split(" ") : new String[0];
String[] consentSkipScopesArray = StringUtils.isNotBlank(consentSkipScopesString) ? consentSkipScopesString.split(" ") : new String[0];

// Convert consentSkipScopesArray into a Set for efficient lookup.
Set<String> consentSkipScopesSet = new HashSet<>(Arrays.asList(consentSkipScopesArray));

StringBuilder filteredScopes = new StringBuilder();

// Iterate over scopesArray and append to filteredScopes if not in consentSkipScopesSet.
for (String scope : scopesArray) {
if (!consentSkipScopesSet.contains(scope)) {
if (filteredScopes.length() > 0) {
filteredScopes.append(" ");
}
filteredScopes.append(scope);
}
}
// The resulting string with the filtered scopes.
scopeString = filteredScopes.toString();

if (!userClaimsConsentOnly && displayScopes && StringUtils.isNotBlank(scopeString)) {
if (StringUtils.isNotBlank(requestedOIDCScopeString)) {
// Remove oidc scopes from the scope list to display.
Expand Down
Loading