Skip to content

Commit 7c5290c

Browse files
committed
Merge branch 'feature/sso-migration' into feature/newCAS-v21.0.0-alpha
2 parents 4c22144 + 71cc430 commit 7c5290c

12 files changed

Lines changed: 193 additions & 13 deletions

File tree

etc/cas/config/cas.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ cas.authn.osf-url.login-with-next=https://{{ .Values.osfDomain }}/login?next=
6969
cas.authn.osf-url.logout=https://{{ .Values.osfDomain }}/logout/
7070
cas.authn.osf-url.resend-confirmation=https://{{ .Values.osfDomain }}/resend/
7171
cas.authn.osf-url.forgot-password=https://{{ .Values.osfDomain }}/forgotpassword/
72+
cas.authn.osf-url.forgot-password-institution=https://{{ .Values.osfDomain }}/forgotpassword-institution/
7273
cas.authn.osf-url.register=https://{{ .Values.osfDomain }}/register/
74+
cas.authn.osf-url.institutions-home=https://{{ .Values.osfDomain }}/institutions/
7375
########################################################################################################################
7476

7577
########################################################################################################################

etc/cas/config/local/cas-local.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ cas.authn.osf-url.login-with-next=http://localhost:5000/login?next=
7676
cas.authn.osf-url.logout=http://localhost:5000/logout/
7777
cas.authn.osf-url.resend-confirmation=http://localhost:5000/resend/
7878
cas.authn.osf-url.forgot-password=http://localhost:5000/forgotpassword/
79+
cas.authn.osf-url.forgot-password-institution=http://localhost:5000/forgotpassword-institution/
7980
cas.authn.osf-url.register=http://localhost:5000/register/
81+
cas.authn.osf-url.institutions-home=http://localhost:5000/institutions/
8082
########################################################################################################################
8183

8284
########################################################################################################################

src/main/java/io/cos/cas/osf/configuration/model/OsfUrlProperties.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,20 @@ public class OsfUrlProperties implements Serializable {
5757
private String resendConfirmation;
5858

5959
/**
60-
* OSF forgot-password page URL
60+
* OSF forgot-password page URL.
6161
*/
6262
private String forgotPassword;
6363

64+
/**
65+
* OSF forgot-password-institutions page URL.
66+
*/
67+
private String forgotPasswordInstitution;
68+
69+
/**
70+
* OSF institutions home page URL.
71+
*/
72+
private String institutionsHome;
73+
6474
/**
6575
* Build the default service URL using OSF login endpoint with OSF home page as destination.
6676
*/

src/main/java/io/cos/cas/osf/web/flow/configurer/OsfCasLoginWebflowConfigurer.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ protected void createDefaultViewStates(final Flow flow) {
8282
createTwoFactorLoginFormView(flow);
8383
createTermsOfServiceConsentLoginFormView(flow);
8484
createInstitutionLoginView(flow);
85+
createUnsupportedInstitutionLoginView(flow);
8586
createOrcidLoginAutoRedirectView(flow);
8687
createDefaultServiceLoginAutoRedirectView(flow);
8788
createOsfCasAuthenticationExceptionViewStates(flow);
@@ -327,6 +328,11 @@ private void createOsfDefaultLoginCheckAction(final Flow flow) {
327328
OsfCasWebflowConstants.TRANSITION_ID_INSTITUTION_LOGIN,
328329
OsfCasWebflowConstants.STATE_ID_OSF_INSTITUTION_LOGIN_CHECK
329330
);
331+
createTransitionForState(
332+
action,
333+
OsfCasWebflowConstants.TRANSITION_ID_UNSUPPORTED_INSTITUTION_LOGIN,
334+
OsfCasWebflowConstants.VIEW_ID_UNSUPPORTED_INSTITUTION_SSO_INIT
335+
);
330336
createTransitionForState(
331337
action,
332338
OsfCasWebflowConstants.TRANSITION_ID_ORCID_LOGIN_AUTO_REDIRECT,
@@ -506,4 +512,17 @@ protected void createInstitutionLoginView(final Flow flow) {
506512
OsfCasWebflowConstants.VIEW_ID_INSTITUTION_SSO_INIT
507513
);
508514
}
515+
516+
/**
517+
* Create the unsupported institution view state to support the OSF feature "I can't find my institution".
518+
*
519+
* @param flow the flow
520+
*/
521+
protected void createUnsupportedInstitutionLoginView(final Flow flow) {
522+
createViewState(
523+
flow,
524+
OsfCasWebflowConstants.VIEW_ID_UNSUPPORTED_INSTITUTION_SSO_INIT,
525+
OsfCasWebflowConstants.VIEW_ID_UNSUPPORTED_INSTITUTION_SSO_INIT
526+
);
527+
}
509528
}

src/main/java/io/cos/cas/osf/web/flow/login/OsfAbstractLoginPreparationAction.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public abstract class OsfAbstractLoginPreparationAction extends AbstractAuthenti
3333

3434
protected static final String PARAMETER_CAMPAIGN_VALUE = "institution";
3535

36+
protected static final String PARAMETER_CAMPAIGN_UNSUPPORTED_INSTITUTION_VALUE = "unsupportedinstitution";
37+
3638
protected static final String PARAMETER_INSTITUTION_ID = "institutionId";
3739

3840
protected static final String PARAMETER_ORCID_CLIENT_TYPE = "orcid";

src/main/java/io/cos/cas/osf/web/flow/login/OsfDefaultLoginPreparationAction.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ protected Event doExecute(RequestContext context) {
5252

5353
final boolean institutionLogin = isInstitutionLogin(context);
5454
final String institutionId = getInstitutionIdFromRequestContext(context);
55+
final boolean unsupportedInstitutionLogin = isUnsupportedInstitutionLogin(context);
5556
final boolean orcidRedirect = isOrcidLoginAutoRedirect(context);
5657
final String orcidLoginUrl = getOrcidLoginUrlFromFlowScope(context);
5758

@@ -74,15 +75,17 @@ protected Event doExecute(RequestContext context) {
7475
encodedServiceUrl,
7576
institutionLogin,
7677
institutionId,
78+
unsupportedInstitutionLogin,
7779
orcidRedirect,
7880
orcidLoginUrl,
7981
defaultService,
8082
defaultServiceUrl
8183
);
8284
} else {
83-
loginContext.setDefaultServiceUrl(encodedServiceUrl);
85+
loginContext.setEncodedServiceUrl(encodedServiceUrl);
8486
loginContext.setInstitutionLogin(institutionLogin);
8587
loginContext.setInstitutionId(institutionId);
88+
loginContext.setUnsupportedInstitutionLogin(unsupportedInstitutionLogin);
8689
loginContext.setOrcidLoginUrl(orcidLoginUrl);
8790
loginContext.setOrcidRedirect(false);
8891
loginContext.setDefaultService(defaultService);
@@ -98,6 +101,8 @@ protected Event doExecute(RequestContext context) {
98101
return error();
99102
} else if (loginContext.isInstitutionLogin()) {
100103
return switchToInstitutionLogin();
104+
} else if (loginContext.isUnsupportedInstitutionLogin()) {
105+
return switchToUnsupportedInstitutionLogin();
101106
} else if (loginContext.isOrcidRedirect()) {
102107
if (StringUtils.isNotBlank(orcidLoginUrl)) {
103108
return autoRedirectToOrcidLogin();
@@ -111,18 +116,23 @@ protected Event doExecute(RequestContext context) {
111116

112117
private boolean isInstitutionLogin(final RequestContext context) {
113118
final String campaign = context.getRequestParameters().get(PARAMETER_CAMPAIGN);
114-
return StringUtils.isNotBlank(campaign) && PARAMETER_CAMPAIGN_VALUE.equals(campaign.toLowerCase());
119+
return StringUtils.isNotBlank(campaign) && PARAMETER_CAMPAIGN_VALUE.equalsIgnoreCase(campaign);
115120
}
116121

117122
private String getInstitutionIdFromRequestContext(final RequestContext context) {
118123
final String institutionId = context.getRequestParameters().get(PARAMETER_INSTITUTION_ID);
119124
return StringUtils.isNotBlank(institutionId) ? institutionId : null;
120125
}
121126

127+
private boolean isUnsupportedInstitutionLogin(final RequestContext context) {
128+
final String campaign = context.getRequestParameters().get(PARAMETER_CAMPAIGN);
129+
return StringUtils.isNotBlank(campaign) && PARAMETER_CAMPAIGN_UNSUPPORTED_INSTITUTION_VALUE.equalsIgnoreCase(campaign);
130+
}
131+
122132
private boolean isOrcidLoginAutoRedirect(final RequestContext context) {
123133
final String orcidRedirect = context.getRequestParameters().get(PARAMETER_ORCID_REDIRECT);
124134
return StringUtils.isNotBlank(orcidRedirect)
125-
&& PARAMETER_ORCID_REDIRECT_VALUE.equals(orcidRedirect.toLowerCase());
135+
&& PARAMETER_ORCID_REDIRECT_VALUE.equalsIgnoreCase(orcidRedirect);
126136
}
127137

128138
private String getOrcidLoginUrlFromFlowScope(final RequestContext context) {
@@ -159,6 +169,10 @@ private Event switchToInstitutionLogin() {
159169
return new Event(this, OsfCasWebflowConstants.TRANSITION_ID_INSTITUTION_LOGIN);
160170
}
161171

172+
private Event switchToUnsupportedInstitutionLogin() {
173+
return new Event(this, OsfCasWebflowConstants.TRANSITION_ID_UNSUPPORTED_INSTITUTION_LOGIN);
174+
}
175+
162176
private Event autoRedirectToOrcidLogin() {
163177
return new Event(this, OsfCasWebflowConstants.TRANSITION_ID_ORCID_LOGIN_AUTO_REDIRECT);
164178
}

src/main/java/io/cos/cas/osf/web/flow/support/OsfCasWebflowConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public interface OsfCasWebflowConstants {
2424

2525
String TRANSITION_ID_INSTITUTION_LOGIN = "switchToInstitutionLogin";
2626

27+
String TRANSITION_ID_UNSUPPORTED_INSTITUTION_LOGIN = "switchToUnsupportedInstitutionLogin";
28+
2729
String TRANSITION_ID_ORCID_LOGIN_AUTO_REDIRECT = "autoRedirectToOrcidLogin";
2830

2931
String TRANSITION_ID_DEFAULT_SERVICE_LOGIN_AUTO_REDIRECT = "autoRedirectToDefaultServiceLogin";
@@ -36,6 +38,8 @@ public interface OsfCasWebflowConstants {
3638

3739
String VIEW_ID_INSTITUTION_SSO_INIT = "casInstitutionLoginView";
3840

41+
String VIEW_ID_UNSUPPORTED_INSTITUTION_SSO_INIT = "casUnsupportedInstitutionLoginView";
42+
3943
String VIEW_ID_ORCID_LOGIN_AUTO_REDIRECT = "casAutoRedirectToOrcidLoginView";
4044

4145
String VIEW_ID_DEFAULT_SERVICE_LOGIN_AUTO_REDIRECT = "casAutoRedirectToDefaultServiceLoginView";

src/main/java/io/cos/cas/osf/web/support/OsfCasLoginContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public class OsfCasLoginContext implements Serializable {
4040

4141
private String institutionId;
4242

43+
private boolean unsupportedInstitutionLogin;
44+
4345
private boolean orcidRedirect;
4446

4547
private String orcidLoginUrl;
@@ -57,6 +59,7 @@ public OsfCasLoginContext (
5759
final String encodedServiceUrl,
5860
final boolean institutionLogin,
5961
final String institutionId,
62+
final boolean unsupportedInstitutionLogin,
6063
final boolean orcidRedirect,
6164
final String orcidLoginUrl,
6265
final boolean defaultService,
@@ -66,6 +69,7 @@ public OsfCasLoginContext (
6669
this.handleErrorName = null;
6770
this.institutionLogin = institutionLogin;
6871
this.institutionId = institutionId;
72+
this.unsupportedInstitutionLogin = unsupportedInstitutionLogin;
6973
this.orcidRedirect = orcidRedirect;
7074
this.orcidLoginUrl = orcidLoginUrl;
7175
this.defaultService = defaultService;

src/main/resources/messages.properties

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ cas.login.resources.osf.donate=Donate
516516
#
517517
# Footer
518518
#
519-
copyright.cos=<span style="white-space: nowrap">Copyright &copy; 2011 &ndash; 2020</span>&#160;\
519+
copyright.cos=<span style="white-space: nowrap">Copyright &copy; 2011 &ndash; 2021</span>&#160;\
520520
<a style="white-space: nowrap" href="https://cos.io">Center for Open Science</a> &#124;&#160;\
521521
<a style="white-space: nowrap" href="https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/TERMS_OF_USE.md">Terms of Use</a>&#160;&#124;&#160;\
522522
<a style="white-space: nowrap" href="https://github.com/CenterForOpenScience/centerforopenscience.org/blob/master/PRIVACY_POLICY.md">Privacy Policy</a>&#160;&#124;&#160;\
@@ -578,15 +578,28 @@ screen.tosconsent.link.cancel=Cancel and go back to OSF
578578
# Institution login page
579579
#
580580
screen.institutionlogin.title=Institution SSO
581-
screen.institutionlogin.tips=Sign in through your institution
581+
screen.institutionlogin.heading=Sign in through your institution
582582
screen.institutionlogin.message.select=If your institution has partnered with OSF, please select its name below and sign in with your institutional credentials. If you do not currently have an OSF account, this will create one for you.
583583
screen.institutionlogin.message.auto=Your institution has partnered with OSF. Please continue to sign in with your institutional credentials. If you do not currently have an OSF account, this will create one for you.
584584
screen.institutionlogin.heading.select=Select your institution
585585
screen.institutionlogin.heading.auto=Your institution
586586
screen.institutionlogin.link.select=Not your institution?
587+
screen.institutionlogin.link.unsupported=I can't find my institution
587588
screen.institutionlogin.button.submit=Sign in
588589
screen.institutionlogin.osf=Sign in with your OSF account
589590
#
591+
# Unsupported Institution
592+
#
593+
screen.unsupp-instn.heading=I can't find my institution
594+
screen.unsupp-instn.message=Signing into the OSF with institutional credentials is enabled for <a href="{0}">OSF Institutions members</a>. If your institution is not yet an OSFI member, choose one of the following sign-in methods.
595+
screen.unsupp-instn.existing.heading=I already have an OSF account
596+
screen.unsupp-instn.existing.message=If you have already have an OSF password, you can sign in to the OSF
597+
screen.unsupp-instn.existing.button=Sign in with OSF
598+
screen.unsupp-instn.existing.setpw.message=If you have not yet set an OSF password for your account, create a password
599+
screen.unsupp-instn.existing.setpw.button=Set a password
600+
screen.unsupp-instn.existing.setpw.label.email=<span class="accesskey">E</span>mail
601+
screen.unsupp-instn.existing.setpw.label.email.accesskey=e
602+
#
590603
# Generic login and logout success page
591604
#
592605
screen.generic.logoutsuccess.title=Signed-out

src/main/resources/static/css/cas.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,7 @@ body {
919919
padding: 1rem 0;
920920
}
921921

922+
.login-instn-card .card-message,
922923
.login-error-card .card-message {
923924
padding: 0;
924925
}

0 commit comments

Comments
 (0)