Skip to content

Commit 96adc39

Browse files
committed
redirect Shib users to page they clicked #1551 #2939
1 parent 8471c02 commit 96adc39

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

src/main/java/edu/harvard/iq/dataverse/Shib.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,11 @@ public class Shib implements java.io.Serializable {
143143
private String friendlyNameForInstitution = "your institution";
144144
private State state;
145145
private String debugSummary;
146+
/**
147+
* After a successful login, we will redirect users to this page (unless
148+
* it's a new account).
149+
*/
150+
private String redirectPage;
146151
// private boolean debug = false;
147152
private String emailAddress;
148153
private boolean useHeaders;
@@ -375,6 +380,7 @@ public void init() {
375380

376381
}
377382
logger.info("Debug summary: " + debugSummary + " (state: " + state + ").");
383+
logger.fine("redirectPage: " + redirectPage);
378384
}
379385

380386
/**
@@ -775,6 +781,9 @@ public String getRootDataverseAlias() {
775781
* logic per https://github.com/IQSS/dataverse/issues/1551
776782
*/
777783
public String getPrettyFacesHomePageString(boolean includeFacetDashRedirect) {
784+
if (redirectPage != null) {
785+
return redirectPage;
786+
}
778787
String plainHomepageString = "/dataverse.xhtml";
779788
String rootDvAlias = getRootDataverseAlias();
780789
if (includeFacetDashRedirect) {
@@ -883,6 +892,14 @@ public void setDebugSummary(String debugSummary) {
883892
this.debugSummary = debugSummary;
884893
}
885894

895+
public String getRedirectPage() {
896+
return redirectPage;
897+
}
898+
899+
public void setRedirectPage(String redirectPage) {
900+
this.redirectPage = redirectPage;
901+
}
902+
886903
private void mutateRequestForDevRandom() throws JsonSyntaxException, JsonIOException {
887904
// set *something*, at least, even if it's just shortened UUIDs
888905
// for (String attr : shibAttrs) {

src/main/webapp/loginpage.xhtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@
8888
<p class="help-block"><h:outputText value="#{bundle['login.institution.blurb']}" escape="false"/></p>
8989

9090
<div id="idpSelect"></div>
91+
<script type="text/javascript">
92+
shibRedirectPage = '?redirectPage=' + '#{LoginPage.redirectPage}';
93+
</script>
9194

9295
<script src="/resources/js/shib/idpselect_config.js" type="text/javascript" language="javascript"></script>
9396

src/main/webapp/resources/js/shib/idpselect_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function IdPSelectUIParms() {
1414
// Approaching via the Discovery Protocol for example
1515
//this.defaultReturn = "https://example.org/Shibboleth.sso/DS?SAMLDS=1&target=https://example.org/secure";
1616

17-
this.defaultReturn = window.location.protocol + "//" + window.location.hostname + "/Shibboleth.sso/Login?SAMLDS=1&target=" + window.location.protocol + "//" + window.location.hostname + "/shib.xhtml";
17+
this.defaultReturn = window.location.protocol + "//" + window.location.hostname + "/Shibboleth.sso/Login?SAMLDS=1&target=" + window.location.protocol + "//" + window.location.hostname + "/shib.xhtml" + shibRedirectPage;
1818
this.defaultReturnIDParam = null;
1919
this.helpURL = 'http://guides.dataverse.org/en/latest/user/account.html';
2020
this.ie6Hack = null; // An array of structures to disable when drawing the pull down (needed to

src/main/webapp/shib.xhtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<f:viewAction action="#{Shib.init}"/>
1515
<!--Only allow existing email to be specified while in development, to test account conversion.-->
1616
<!--<f:viewParam name="exisitingEmail" value="#{Shib.existingEmail}"/>-->
17+
<f:viewParam name="redirectPage" value="#{Shib.redirectPage}"/>
1718
</f:metadata>
1819
<ui:composition template="/dataverse_template.xhtml">
1920
<ui:param name="pageTitle" value="Shib"/>

0 commit comments

Comments
 (0)