Skip to content

Commit

Permalink
fix(oxtrust-server): postLogoutRedirectUris as multivalued
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhar16 committed Jul 3, 2023
1 parent 3730a70 commit 8d5510c
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public class UpdateClientAction implements Serializable {
private List<String> loginUris = Lists.newArrayList();
private List<String> logoutUris;
private List<String> clientlogoutUris;
private List<String> redirectLogoutUrl;
private List<String> clientBackChannellogoutUris;
private List<String> claimRedirectURIList;
private List<String> additionalAudienceList;
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -420,6 +424,7 @@ public String save() throws Exception {
}
updateLoginURIs();
updateLogoutURIs();
updateRedirectLogoutUrls();
updateBackChannelLogoutURIs();
updateScopes();
updateClaims();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -927,6 +949,10 @@ public void cancelClientLogoutUri() {
this.availableClientlogoutUri = HTTPS;
}

public void cancelRedirectLogoutUrl() {
this.availableRedirectLogoutUrl = HTTPS;
}

public void cancelClientBackLogoutUri() {
this.availableClientBacklogoutUri = HTTPS;
}
Expand Down Expand Up @@ -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<String> tmpUris = new ArrayList<String>();
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<String>());
Expand Down Expand Up @@ -2195,4 +2233,20 @@ public String getScopePattern() {
public void setScopePattern(String scopePattern) {
this.scopePattern = scopePattern;
}

public List<String> getRedirectLogoutUrl() {
return redirectLogoutUrl;
}

public void setRedirectLogoutUrl(List<String> redirectLogoutUrl) {
this.redirectLogoutUrl = redirectLogoutUrl;
}

public String getAvailableRedirectLogoutUrl() {
return availableRedirectLogoutUrl;
}

public void setAvailableRedirectLogoutUrl(String availableRedirectLogoutUrl) {
this.availableRedirectLogoutUrl = availableRedirectLogoutUrl;
}
}
6 changes: 3 additions & 3 deletions server/src/main/java/org/gluu/oxtrust/model/OxAuthClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public class OxAuthClient extends Entry implements Serializable {
private List<String> oxAuthRedirectURIs;

@AttributeName(name = "oxAuthPostLogoutRedirectURI")
private String oxAuthPostLogoutRedirectURIs;
private List<String> oxAuthPostLogoutRedirectURIs;

@AttributeName(name = "oxAuthScope")
private List<String> oxAuthScopes;
Expand Down Expand Up @@ -301,11 +301,11 @@ public void setOxAuthRedirectURIs(List<String> oxAuthRedirectURIs) {
this.oxAuthRedirectURIs = oxAuthRedirectURIs;
}

public String getOxAuthPostLogoutRedirectURIs() {
public List<String> getOxAuthPostLogoutRedirectURIs() {
return oxAuthPostLogoutRedirectURIs;
}

public void setOxAuthPostLogoutRedirectURIs(String oxAuthPostLogoutRedirectURIs) {
public void setOxAuthPostLogoutRedirectURIs(List<String> oxAuthPostLogoutRedirectURIs) {
this.oxAuthPostLogoutRedirectURIs = oxAuthPostLogoutRedirectURIs;
}

Expand Down
41 changes: 35 additions & 6 deletions server/src/main/webapp/WEB-INF/incl/client/clientForm.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -692,12 +692,41 @@
</h:panelGroup>
</h:panelGroup>
</b:panel>
<ox:decorate id="redirectLogoutUrls" label="#{msgs['clientForm.redirectLogoutURIs']}"
leftClass="col-sm-6" rightClass="col-sm-6">
<h:inputText id="redirectLogoutUrlsId"
value="#{_client.oxAuthPostLogoutRedirectURIs}" style="width:100%"
styleClass="form-control redirectLogoutUrlsId" />
</ox:decorate>

<b:panel title="#{msgs['clientForm.redirectLogoutURIs']}"
id="redirectLogoutUrl" look="primary">
<h:panelGroup id="selectedRedirectLogoutUrlId">
<h:panelGroup columns="1" width="100%" border="0"
cellpadding="0" cellspacing="0">
<a4j:repeat value="#{_clientAction.redirectLogoutUrl}"
rowKeyVar="_urisIdx" var="_uri" iterationStatusVar="loop">
<div class="row-fluid">
<div class="#{(loop.index % 2 == 0) ?'odd':'even'}"
style="overflow-x: scroll;">
<h:outputText value="#{empty _uri ? _uri : _uri}" />
<h:outputText value="&#160;" />
<div class="span6 pull-right">
<a4j:commandLink
styleClass="glyphicon glyphicon-remove"
action="#{_clientAction.removeRedirectLogoutUrl(_uri)}"
execute="@this" render="selectedRedirectLogoutUrlId"
eventsQueue="clientQueue">
<!-- <h:graphicImage value="/img/remove.gif" /> -->
</a4j:commandLink>
</div>
</div>
</div>
<br />
</a4j:repeat>
<p:spacer height="16" />
<a4j:commandButton
styleClass="btn btn-primary addLogoutUriButton"
style="margin-top:5px" value="Add Post Logout Redirect URI"
oncomplete="#{rich:component('redirectLogoutUrlsId:inputText')}.show();"
execute="@this" eventsQueue="clientQueue" />
</h:panelGroup>
</h:panelGroup>
</b:panel>

<b:panel title="Back Channel Logout URI"
id="backchannelLogoutUri" look="primary">
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/webapp/client/addClient.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
queue="clientQueue" render="selectedClientUrisId"
text="#{updateClientAction.availableClientlogoutUri}"
textId="clientLogoutTextId" />

<ox:inputTextDialog
acceptMethod="#{updateClientAction.acceptSelectRedirectLogoutUrl()}"
cancelMethod="#{updateClientAction.cancelRedirectLogoutUrl()}"
dialogWidth="600" id="redirectLogoutUrlsId"
inputLabel="Add #{msgs['clientForm.redirectLogoutURIs']}" inputWidth="80"
label="#{msgs['clientForm.redirectLogoutURIs']}" maxLength="256"
queue="clientQueue" render="selectedRedirectLogoutUrlId"
text="#{updateClientAction.availableRedirectLogoutUrl}"
textId="redirectLogoutURIstextId" />

<ox:inputTextDialog
acceptMethod="#{updateClientAction.acceptSelectClientBackLogoutUri()}"
Expand Down
10 changes: 10 additions & 0 deletions server/src/main/webapp/client/updateClient.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@
render="selectedClientUrisId"
text="#{updateClientAction.availableClientlogoutUri}"
textId="clientLogoutTextId" />

<ox:inputTextDialog
acceptMethod="#{updateClientAction.acceptSelectRedirectLogoutUrl()}"
cancelMethod="#{updateClientAction.cancelRedirectLogoutUrl()}"
dialogWidth="600" id="redirectLogoutUrlsId"
inputLabel="Add #{msgs['clientForm.redirectLogoutURIs']}" inputWidth="80"
label="#{msgs['clientForm.redirectLogoutURIs']}" maxLength="256"
queue="clientQueue" render="selectedRedirectLogoutUrlId"
text="#{updateClientAction.availableRedirectLogoutUrl}"
textId="redirectLogoutURIstextId" />

<ox:inputTextDialog
acceptMethod="#{updateClientAction.acceptSelectClientBackLogoutUri()}"
Expand Down

0 comments on commit 8d5510c

Please sign in to comment.