From 3730a70e8e1a842564bb2fa45a9029ddc1c4782e Mon Sep 17 00:00:00 2001 From: shekhar16 Date: Sun, 5 Feb 2023 01:24:21 +0530 Subject: [PATCH 1/2] feat: added search box to filter scopes --- .../oxtrust/action/UpdateClientAction.java | 26 +++++++++++++++---- server/src/main/webapp/client/addClient.xhtml | 5 ++-- .../src/main/webapp/client/updateClient.xhtml | 7 ++--- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java b/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java index 6c4fb47e5..46741dbc1 100644 --- a/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java +++ b/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java @@ -201,6 +201,7 @@ public class UpdateClientAction implements Serializable { private String spontaneousScopeCustomScript; private String introspectionCustomScript; private String rptClaimsScript; + private String scopePattern; Pattern domainPattern = Pattern.compile("^((?!-)[A-Za-z0-9-]{1,63}(? client.getAttributes().getPostAuthnScripts().contains(entity.getEntity().getDn())) @@ -1489,14 +1492,18 @@ public List getScripts(CustomScriptType type) { } public void searchAvailableScopes() { - if (this.availableScopes != null) { - selectAddedScopes(); - return; - } + //if (this.availableScopes != null) { + // selectAddedScopes(); + // return; + //} List> tmpAvailableScopes = new ArrayList>(); List scopes = new ArrayList(); try { - scopes = scopeService.getAllScopesList(1000); + if(scopePattern != null && !scopePattern.isEmpty()) { + scopes = scopeService.searchScopes(scopePattern, 0); + }else { + scopes = scopeService.getAllScopesList(1000); + } } catch (Exception e) { e.printStackTrace(); } @@ -2164,6 +2171,7 @@ public void setResources(List resources) { this.resources = resources; } + public List getClientBackChannellogoutUris() { return clientBackChannellogoutUris; } @@ -2179,4 +2187,12 @@ public String getAvailableClientBacklogoutUri() { public void setAvailableClientBacklogoutUri(String availableClientBacklogoutUri) { this.availableClientBacklogoutUri = availableClientBacklogoutUri; } + + public String getScopePattern() { + return scopePattern; + } + + public void setScopePattern(String scopePattern) { + this.scopePattern = scopePattern; + } } diff --git a/server/src/main/webapp/client/addClient.xhtml b/server/src/main/webapp/client/addClient.xhtml index 43b320eea..12a203fe7 100644 --- a/server/src/main/webapp/client/addClient.xhtml +++ b/server/src/main/webapp/client/addClient.xhtml @@ -78,11 +78,12 @@ + searchResult="#{updateClientAction.availableScopes}" + searchPattern="#{updateClientAction.scopePattern}" /> - + searchResult="#{updateClientAction.availableScopes}" + searchPattern="#{updateClientAction.scopePattern}" /> + Date: Sun, 25 Jun 2023 23:11:59 +0530 Subject: [PATCH 2/2] fix(oxtrust-server): postLogoutRedirectUris as multivalued --- .../oxtrust/action/UpdateClientAction.java | 54 +++++++++++++++++++ .../org/gluu/oxtrust/model/OxAuthClient.java | 6 +-- .../WEB-INF/incl/client/clientForm.xhtml | 41 +++++++++++--- server/src/main/webapp/client/addClient.xhtml | 10 ++++ .../src/main/webapp/client/updateClient.xhtml | 10 ++++ 5 files changed, 112 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java b/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java index 46741dbc1..524304749 100644 --- a/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java +++ b/server/src/main/java/org/gluu/oxtrust/action/UpdateClientAction.java @@ -162,6 +162,7 @@ public class UpdateClientAction implements Serializable { private List loginUris = Lists.newArrayList(); private List logoutUris; private List clientlogoutUris; + private List redirectLogoutUrl; private List clientBackChannellogoutUris; private List claimRedirectURIList; private List additionalAudienceList; @@ -188,6 +189,7 @@ public class UpdateClientAction implements Serializable { private String availableLoginUri = HTTPS; private String availableLogoutUri = HTTPS; private String availableClientlogoutUri = HTTPS; + private String availableRedirectLogoutUrl = HTTPS; private String availableClientBacklogoutUri = HTTPS; private String availableContact = ""; private String availableRequestUri = HTTPS; @@ -264,6 +266,7 @@ public String add() throws Exception { this.spontaneousScopesScripts = Lists.newArrayList(); this.backchannelLogoutUri = getStringFromList(client.getAttributes().getBackchannelLogoutUri()); this.tlsSubjectDn = client.getAttributes().getTlsClientAuthSubjectDn(); + this.redirectLogoutUrl = getNonEmptyStringList(client.getOxAuthPostLogoutRedirectURIs()); this.scopePattern = ""; searchAvailableCustomScriptsforAcr(); } catch (BasePersistenceException ex) { @@ -325,6 +328,7 @@ public String update() throws Exception { this.loginUris = getNonEmptyStringList(client.getOxAuthRedirectURIs()); this.clientlogoutUris = getNonEmptyStringList(client.getLogoutUri()); + this.redirectLogoutUrl= getNonEmptyStringList(client.getOxAuthPostLogoutRedirectURIs()); this.clientBackChannellogoutUris = getNonEmptyStringList(client.getAttributes().getBackchannelLogoutUri()); this.scopes = getInitialEntries(); this.claims = getInitialClaimDisplayNameEntries(); @@ -420,6 +424,7 @@ public String save() throws Exception { } updateLoginURIs(); updateLogoutURIs(); + updateRedirectLogoutUrls(); updateBackChannelLogoutURIs(); updateScopes(); updateClaims(); @@ -537,6 +542,10 @@ public void removeLogoutURI(String uri) { public void removeClientLogoutURI(String uri) { removeFromList(this.clientlogoutUris, uri); } + + public void removeRedirectLogoutUrl(String uri) { + removeFromList(this.redirectLogoutUrl, uri); + } public void removeClientBackLogoutURI(String uri) { removeFromList(this.clientBackChannellogoutUris, uri); @@ -807,6 +816,19 @@ && checkBlackListRedirectUris(availableLogoutUri)) { this.availableLogoutUri = HTTPS; } + public void acceptSelectRedirectLogoutUrl() { + if (StringHelper.isEmpty(this.availableRedirectLogoutUrl)) { + return; + } + if (this.availableRedirectLogoutUrl.equalsIgnoreCase(HTTPS)) { + return; + } + if (!this.redirectLogoutUrl.contains(this.availableRedirectLogoutUrl)) { + this.redirectLogoutUrl.add(this.availableRedirectLogoutUrl); + } + this.availableRedirectLogoutUrl = HTTPS; + } + public void acceptSelectClientLogoutUri() { if (StringHelper.isEmpty(this.availableClientlogoutUri)) { return; @@ -927,6 +949,10 @@ public void cancelClientLogoutUri() { this.availableClientlogoutUri = HTTPS; } + public void cancelRedirectLogoutUrl() { + this.availableRedirectLogoutUrl = HTTPS; + } + public void cancelClientBackLogoutUri() { this.availableClientBacklogoutUri = HTTPS; } @@ -976,6 +1002,18 @@ private void updateLogoutURIs() { this.client.setLogoutUri(tmpUris); } + private void updateRedirectLogoutUrls() { + if (this.redirectLogoutUrl == null || this.redirectLogoutUrl.size() == 0) { + this.client.setOxAuthPostLogoutRedirectURIs(null); + return; + } + List tmpUris = new ArrayList(); + for (String uri : this.redirectLogoutUrl) { + tmpUris.add(StringHelper.trimAll(uri)); + } + this.client.setOxAuthPostLogoutRedirectURIs(tmpUris); + } + private void updateBackChannelLogoutURIs() { if (this.clientBackChannellogoutUris == null || this.clientBackChannellogoutUris.size() == 0) { client.getAttributes().setBackchannelLogoutUri(new ArrayList()); @@ -2195,4 +2233,20 @@ public String getScopePattern() { public void setScopePattern(String scopePattern) { this.scopePattern = scopePattern; } + + public List getRedirectLogoutUrl() { + return redirectLogoutUrl; + } + + public void setRedirectLogoutUrl(List redirectLogoutUrl) { + this.redirectLogoutUrl = redirectLogoutUrl; + } + + public String getAvailableRedirectLogoutUrl() { + return availableRedirectLogoutUrl; + } + + public void setAvailableRedirectLogoutUrl(String availableRedirectLogoutUrl) { + this.availableRedirectLogoutUrl = availableRedirectLogoutUrl; + } } diff --git a/server/src/main/java/org/gluu/oxtrust/model/OxAuthClient.java b/server/src/main/java/org/gluu/oxtrust/model/OxAuthClient.java index d0dee9055..f7062de39 100644 --- a/server/src/main/java/org/gluu/oxtrust/model/OxAuthClient.java +++ b/server/src/main/java/org/gluu/oxtrust/model/OxAuthClient.java @@ -62,7 +62,7 @@ public class OxAuthClient extends Entry implements Serializable { private List oxAuthRedirectURIs; @AttributeName(name = "oxAuthPostLogoutRedirectURI") - private String oxAuthPostLogoutRedirectURIs; + private List oxAuthPostLogoutRedirectURIs; @AttributeName(name = "oxAuthScope") private List oxAuthScopes; @@ -301,11 +301,11 @@ public void setOxAuthRedirectURIs(List oxAuthRedirectURIs) { this.oxAuthRedirectURIs = oxAuthRedirectURIs; } - public String getOxAuthPostLogoutRedirectURIs() { + public List getOxAuthPostLogoutRedirectURIs() { return oxAuthPostLogoutRedirectURIs; } - public void setOxAuthPostLogoutRedirectURIs(String oxAuthPostLogoutRedirectURIs) { + public void setOxAuthPostLogoutRedirectURIs(List oxAuthPostLogoutRedirectURIs) { this.oxAuthPostLogoutRedirectURIs = oxAuthPostLogoutRedirectURIs; } diff --git a/server/src/main/webapp/WEB-INF/incl/client/clientForm.xhtml b/server/src/main/webapp/WEB-INF/incl/client/clientForm.xhtml index 3bedca316..3000b7e6e 100644 --- a/server/src/main/webapp/WEB-INF/incl/client/clientForm.xhtml +++ b/server/src/main/webapp/WEB-INF/incl/client/clientForm.xhtml @@ -692,12 +692,41 @@ - - - + + + + + +
+
+ + +
+ + + +
+
+
+
+
+ + +
+
+
diff --git a/server/src/main/webapp/client/addClient.xhtml b/server/src/main/webapp/client/addClient.xhtml index 12a203fe7..758e9c381 100644 --- a/server/src/main/webapp/client/addClient.xhtml +++ b/server/src/main/webapp/client/addClient.xhtml @@ -152,6 +152,16 @@ queue="clientQueue" render="selectedClientUrisId" text="#{updateClientAction.availableClientlogoutUri}" textId="clientLogoutTextId" /> + + + +