Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ids9941 301 return v3 #166

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void doFilter(
// FIXME: add similar logic as above to redirect Camunda login pages..

chain.doFilter(request, resp); // continue onwards with chain
statusOverride(resp);
statusOverride(resp, req);
return;
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void doFilter(
// FIXME: add similar logic as above to redirect Camunda login pages..

chain.doFilter(request, resp); // continue onwards with chain
statusOverride(resp);
statusOverride(resp, req);
return;
}
else {
Expand Down
18 changes: 15 additions & 3 deletions cws-core/src/main/java/jpl/cws/core/web/CwsSecurityFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,19 @@ public abstract class CwsSecurityFilter implements javax.servlet.Filter {
protected AuthorizationService authorizationService;

protected String cwsSecurityScheme;


private String cwsWebPort;
private String cwsSSLPort;

public void init(FilterConfig filterConfig) {
try {
cwsSecurityScheme = filterConfig.getInitParameter("identityPluginType");
cwsWebPort = filterConfig.getInitParameter("cwsWebPort");
cwsSSLPort = filterConfig.getInitParameter("cwsSSLPort");
log.debug("CWS Security scheme is: " + cwsSecurityScheme);
log.debug("CWS cwsWebPort is: " + cwsWebPort);
log.debug("CWS cwsSSLPort is: " + cwsSSLPort);


this.contextPath = filterConfig.getServletContext().getContextPath();

Expand Down Expand Up @@ -305,12 +313,16 @@ else if (path.toLowerCase().endsWith("/logout")) {
}

// Simple override of http return for redirect code when http request is valid
protected void statusOverride(HttpServletResponse resp){
protected void statusOverride(HttpServletResponse resp, HttpServletRequest req){
if (resp.getStatus() == 200){
resp.setStatus(301);
String newURL = getBaseUrl(req);
newURL = newURL.replaceFirst("http:", "https:");
newURL = newURL.replaceFirst(cwsWebPort, cwsSSLPort);
resp.setHeader("Location", newURL);
}
}

protected void logRequestInfo(HttpServletRequest req) {
// Log all of the headers
Enumeration<String> reqHeaderNames = req.getHeaderNames();
Expand Down
8 changes: 7 additions & 1 deletion cws-installer/src/main/java/jpl/cws/task/CwsInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ private static void setIdentityPluginType() throws UnsupportedOperationException
}
}


private static void setupDatabase() {
cws_db_type = getPreset("database_type");

Expand Down Expand Up @@ -2481,6 +2480,9 @@ private static void updateFiles() throws IOException {
content = content.replace("__CWS_SECURITY_FILTER_CLASS__", cws_security_filter_class);
content = content.replace("__CWS_ADMIN_USERNAME__", cws_user);
content = content.replace("__CWS_TOKEN_EXPIRATION_MINUTES__", Integer.toString(Integer.parseInt(cws_token_expiration_hours) * 60));
content = content.replace("__CWS_WEB_PORT__", cws_tomcat_connector_port);
content = content.replace("__CWS_SSL_PORT__", cws_tomcat_ssl_port);


if (cws_auth_scheme.equals("CAMUNDA")) {
content = content.replace("__CWS_ADMIN_FIRSTNAME__", cws_user_firstname);
Expand Down Expand Up @@ -2511,6 +2513,8 @@ private static void updateFiles() throws IOException {
content = getFileContents(filePath);
content = content.replace("__CWS_IDENTITY_PLUGIN_TYPE__", cws_auth_scheme);
content = content.replace("__CWS_SECURITY_FILTER_CLASS__", cws_security_filter_class);
content = content.replace("__CWS_WEB_PORT__", cws_tomcat_connector_port);
content = content.replace("__CWS_SSL_PORT__", cws_tomcat_ssl_port);

writeToFile(filePath, content);
copy(
Expand All @@ -2523,6 +2527,8 @@ private static void updateFiles() throws IOException {
content = getFileContents(filePath);
content = content.replace("__CWS_IDENTITY_PLUGIN_TYPE__", cws_auth_scheme);
content = content.replace("__CWS_SECURITY_FILTER_CLASS__", cws_security_filter_class);
content = content.replace("__CWS_WEB_PORT__", cws_tomcat_connector_port);
content = content.replace("__CWS_SSL_PORT__", cws_tomcat_ssl_port);
writeToFile(filePath, content);
copy(
Paths.get(config_work_dir + SEP + "engine-rest_mods" + SEP + "web.xml"),
Expand Down
8 changes: 8 additions & 0 deletions install/camunda_mods/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@
<param-name>identityPluginType</param-name>
<param-value>__CWS_IDENTITY_PLUGIN_TYPE__</param-value>
</init-param>
<init-param>
<param-name>cwsWebPort</param-name>
<param-value>__CWS_WEB_PORT__</param-value>
</init-param>
<init-param>
<param-name>cwsSSLPort</param-name>
<param-value>__CWS_SSL_PORT__</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CwsSecurityFilter</filter-name>
Expand Down
8 changes: 8 additions & 0 deletions install/tomcat_conf/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,14 @@
<param-name>identityPluginType</param-name>
<param-value>__CWS_IDENTITY_PLUGIN_TYPE__</param-value>
</init-param>
<init-param>
<param-name>cwsWebPort</param-name>
<param-value>__CWS_WEB_PORT__</param-value>
</init-param>
<init-param>
<param-name>cwsSSLPort</param-name>
<param-value>__CWS_SSL_PORT__</param-value>
</init-param>
<init-param>
<param-name>adminUserId</param-name>
<param-value>__CWS_ADMIN_USERNAME__</param-value>
Expand Down