Skip to content

Commit

Permalink
redirect Shib users to page they clicked #1551 #2939
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Mar 4, 2016
1 parent 8471c02 commit 96adc39
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/Shib.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public class Shib implements java.io.Serializable {
private String friendlyNameForInstitution = "your institution";
private State state;
private String debugSummary;
/**
* After a successful login, we will redirect users to this page (unless
* it's a new account).
*/
private String redirectPage;
// private boolean debug = false;
private String emailAddress;
private boolean useHeaders;
Expand Down Expand Up @@ -375,6 +380,7 @@ public void init() {

}
logger.info("Debug summary: " + debugSummary + " (state: " + state + ").");
logger.fine("redirectPage: " + redirectPage);
}

/**
Expand Down Expand Up @@ -775,6 +781,9 @@ public String getRootDataverseAlias() {
* logic per https://github.com/IQSS/dataverse/issues/1551
*/
public String getPrettyFacesHomePageString(boolean includeFacetDashRedirect) {
if (redirectPage != null) {
return redirectPage;
}
String plainHomepageString = "/dataverse.xhtml";
String rootDvAlias = getRootDataverseAlias();
if (includeFacetDashRedirect) {
Expand Down Expand Up @@ -883,6 +892,14 @@ public void setDebugSummary(String debugSummary) {
this.debugSummary = debugSummary;
}

public String getRedirectPage() {
return redirectPage;
}

public void setRedirectPage(String redirectPage) {
this.redirectPage = redirectPage;
}

private void mutateRequestForDevRandom() throws JsonSyntaxException, JsonIOException {
// set *something*, at least, even if it's just shortened UUIDs
// for (String attr : shibAttrs) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/loginpage.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@
<p class="help-block"><h:outputText value="#{bundle['login.institution.blurb']}" escape="false"/></p>

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/resources/js/shib/idpselect_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function IdPSelectUIParms() {
// Approaching via the Discovery Protocol for example
//this.defaultReturn = "https://example.org/Shibboleth.sso/DS?SAMLDS=1&target=https://example.org/secure";

this.defaultReturn = window.location.protocol + "//" + window.location.hostname + "/Shibboleth.sso/Login?SAMLDS=1&target=" + window.location.protocol + "//" + window.location.hostname + "/shib.xhtml";
this.defaultReturn = window.location.protocol + "//" + window.location.hostname + "/Shibboleth.sso/Login?SAMLDS=1&target=" + window.location.protocol + "//" + window.location.hostname + "/shib.xhtml" + shibRedirectPage;
this.defaultReturnIDParam = null;
this.helpURL = 'http://guides.dataverse.org/en/latest/user/account.html';
this.ie6Hack = null; // An array of structures to disable when drawing the pull down (needed to
Expand Down
1 change: 1 addition & 0 deletions src/main/webapp/shib.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<f:viewAction action="#{Shib.init}"/>
<!--Only allow existing email to be specified while in development, to test account conversion.-->
<!--<f:viewParam name="exisitingEmail" value="#{Shib.existingEmail}"/>-->
<f:viewParam name="redirectPage" value="#{Shib.redirectPage}"/>
</f:metadata>
<ui:composition template="/dataverse_template.xhtml">
<ui:param name="pageTitle" value="Shib"/>
Expand Down

0 comments on commit 96adc39

Please sign in to comment.