forked from mff-uk/odcs
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'hotfix/UV_Core_v2.0.2'
- Loading branch information
Showing
27 changed files
with
548 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
frontend/src/main/java/cz/cuni/mff/xrg/odcs/frontend/auth/UVAuthenticationDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cz.cuni.mff.xrg.odcs.frontend.auth; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
|
||
import org.springframework.security.web.authentication.WebAuthenticationDetails; | ||
|
||
public class UVAuthenticationDetails extends WebAuthenticationDetails { | ||
|
||
private String forwardedHost; | ||
|
||
private String host; | ||
|
||
private String scheme; | ||
|
||
private static final String HTTP_HEADER_FORWARDED_HOST = "X-Forwarded-Host"; | ||
|
||
private static final String HTTP_HEADER_HOST = "Host"; | ||
|
||
private static final String HTTP_HEADER_SCHEME = "Scheme"; | ||
|
||
public UVAuthenticationDetails(HttpServletRequest request) { | ||
super(request); | ||
|
||
this.forwardedHost = request.getHeader(HTTP_HEADER_FORWARDED_HOST); | ||
this.host = request.getHeader(HTTP_HEADER_HOST); | ||
this.scheme = request.getHeader(HTTP_HEADER_SCHEME); | ||
} | ||
|
||
public String getForwardedHost() { | ||
return forwardedHost; | ||
} | ||
|
||
public String getHost() { | ||
return host; | ||
} | ||
|
||
public String getScheme() { | ||
return scheme; | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
frontend/src/main/java/cz/cuni/mff/xrg/odcs/frontend/auth/UVCasAuthenticationEntryPoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package cz.cuni.mff.xrg.odcs.frontend.auth; | ||
|
||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
import org.jasig.cas.client.util.CommonUtils; | ||
import org.springframework.security.cas.web.CasAuthenticationEntryPoint; | ||
import org.springframework.security.cas.web.CasAuthenticationFilter; | ||
|
||
/** | ||
* Used by the <code>ExceptionTranslationFilter</code> to commence authentication via the JA-SIG Central | ||
* Authentication Service (CAS). | ||
* <p> | ||
* The user's browser will be redirected to the JA-SIG CAS enterprise-wide login page. This page is specified by the <code>loginUrl</code> property. Once login | ||
* is complete, the CAS login page will redirect to the page indicated by the <code>service</code> property. The <code>service</code> is a HTTP URL belonging to | ||
* the current application. The <code>service</code> URL is monitored by the {@link CasAuthenticationFilter}, which will validate the CAS login was successful. | ||
* | ||
* @author Ben Alex | ||
* @author Scott Battaglia | ||
*/ | ||
public class UVCasAuthenticationEntryPoint extends CasAuthenticationEntryPoint { | ||
|
||
private static final String HTTP_HEADER_FORWARDED_HOST = "X-Forwarded-Host"; | ||
|
||
private static final String HTTP_HEADER_HOST = "Host"; | ||
|
||
private static final String HTTP_HEADER_SCHEME = "Scheme"; | ||
|
||
private boolean behindProxy = false; | ||
|
||
/** | ||
* Constructs a new Service Url. The default implementation relies on the CAS client to do the bulk of the work. | ||
* | ||
* @param request | ||
* the HttpServletRequest | ||
* @param response | ||
* the HttpServlet Response | ||
* @return the constructed service url. CANNOT be NULL. | ||
*/ | ||
|
||
protected String createServiceUrl(final HttpServletRequest request, final HttpServletResponse response) { | ||
|
||
String serviceUrl = null; | ||
|
||
if (behindProxy) { | ||
|
||
String forwardedHost = request.getHeader(HTTP_HEADER_FORWARDED_HOST); | ||
String host = request.getHeader(HTTP_HEADER_HOST); | ||
String scheme = request.getHeader(HTTP_HEADER_SCHEME) != null ? request.getHeader(HTTP_HEADER_SCHEME) : "http"; | ||
|
||
String resultingHost = null; | ||
|
||
if (forwardedHost != null) | ||
resultingHost = forwardedHost; | ||
else if (host != null) | ||
resultingHost = host; | ||
|
||
if(resultingHost == null){ | ||
throw new IllegalStateException("if behindProxy=true please ensure that either header " + HTTP_HEADER_FORWARDED_HOST + " or " + HTTP_HEADER_HOST + " is sent!"); | ||
} | ||
|
||
serviceUrl = scheme + "://" + resultingHost + this.getServiceProperties().getService(); | ||
} | ||
else | ||
serviceUrl = this.getServiceProperties().getService(); | ||
|
||
return CommonUtils.constructServiceUrl(null, response, serviceUrl, null, this.getServiceProperties().getArtifactParameter(), this.getEncodeServiceUrlWithSessionId()); | ||
} | ||
|
||
public void setBehindProxy(boolean behindProxy) { | ||
this.behindProxy = behindProxy; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.