aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalii Diravka <vitalii.diravka@gmail.com>2019-02-23 21:51:48 +0200
committerVitalii Diravka <vitalii@apache.org>2019-03-01 14:22:33 +0200
commitfee4b1cdc1a1bf4ac3dfdbbf435a5696540ce59a (patch)
treeb647deffade492f6a3b6c6359a29d7c4ebeb7c64
parent469be17597e7b7c6bc1de9863dcb6c5604a55f0c (diff)
DRILL-7052: Relative path for URL redirection
-rw-r--r--drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/AuthDynamicFeature.java6
-rw-r--r--drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/WebUiPageTree.java2
-rw-r--r--drill-yarn/src/main/resources/drill-am/login.ftl2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogInLogOutResources.java2
-rw-r--r--exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/auth/AuthDynamicFeature.java5
-rw-r--r--exec/java-exec/src/main/resources/rest/login.ftl37
-rw-r--r--exec/java-exec/src/main/resources/rest/mainLogin.ftl26
7 files changed, 38 insertions, 42 deletions
diff --git a/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/AuthDynamicFeature.java b/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/AuthDynamicFeature.java
index c882fe027..3a1747842 100644
--- a/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/AuthDynamicFeature.java
+++ b/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/AuthDynamicFeature.java
@@ -33,7 +33,6 @@ import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.FeatureContext;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
-import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
@@ -83,13 +82,12 @@ public class AuthDynamicFeature implements DynamicFeature {
private static AuthCheckFilter INSTANCE = new AuthCheckFilter();
@Override
- public void filter(ContainerRequestContext requestContext)
- throws IOException {
+ public void filter(ContainerRequestContext requestContext) {
final SecurityContext sc = requestContext.getSecurityContext();
if (!isUserLoggedIn(sc)) {
try {
final String destResource = URLEncoder.encode(
- requestContext.getUriInfo().getRequestUri().toString(), "UTF-8");
+ requestContext.getUriInfo().getRequestUri().getPath(), "UTF-8");
final URI loginURI = requestContext.getUriInfo().getBaseUriBuilder()
.path(LogInLogOutPages.LOGIN_RESOURCE)
.queryParam(LogInLogOutPages.REDIRECT_QUERY_PARM, destResource)
diff --git a/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/WebUiPageTree.java b/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/WebUiPageTree.java
index fc44e4577..58a59d382 100644
--- a/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/WebUiPageTree.java
+++ b/drill-yarn/src/main/java/org/apache/drill/yarn/appMaster/http/WebUiPageTree.java
@@ -117,7 +117,7 @@ public class WebUiPageTree extends PageTree {
final HttpSession session = request.getSession(true);
final URI destURI = UriBuilder
.fromUri(URLDecoder.decode(redirect, "UTF-8")).build();
- session.setAttribute(FormAuthenticator.__J_URI, destURI.toString());
+ session.setAttribute(FormAuthenticator.__J_URI, destURI.getPath());
}
return new Viewable("/drill-am/login.ftl", toModel(sc, (Object) null));
diff --git a/drill-yarn/src/main/resources/drill-am/login.ftl b/drill-yarn/src/main/resources/drill-am/login.ftl
index 3f34a51b3..e7fdc48ee 100644
--- a/drill-yarn/src/main/resources/drill-am/login.ftl
+++ b/drill-yarn/src/main/resources/drill-am/login.ftl
@@ -40,4 +40,4 @@
</form>
</div>
</#macro>
-<@page_html/> \ No newline at end of file
+<@page_html/>
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogInLogOutResources.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogInLogOutResources.java
index 324b7018b..0abe2c5b4 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogInLogOutResources.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/LogInLogOutResources.java
@@ -69,7 +69,7 @@ public class LogInLogOutResources {
// is forwarded to the redirect page.
final HttpSession session = request.getSession(true);
final URI destURI = UriBuilder.fromUri(URLDecoder.decode(redirect, "UTF-8")).build();
- session.setAttribute(FormAuthenticator.__J_URI, destURI.toString());
+ session.setAttribute(FormAuthenticator.__J_URI, destURI.getPath());
}
}
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/auth/AuthDynamicFeature.java b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/auth/AuthDynamicFeature.java
index 7bcf430cb..fc6952116 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/auth/AuthDynamicFeature.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/server/rest/auth/AuthDynamicFeature.java
@@ -31,7 +31,6 @@ import javax.ws.rs.container.ResourceInfo;
import javax.ws.rs.core.FeatureContext;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
-import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
@@ -75,12 +74,12 @@ public class AuthDynamicFeature implements DynamicFeature {
private static AuthCheckFilter INSTANCE = new AuthCheckFilter();
@Override
- public void filter(ContainerRequestContext requestContext) throws IOException {
+ public void filter(ContainerRequestContext requestContext) {
final SecurityContext sc = requestContext.getSecurityContext();
if (!isUserLoggedIn(sc)) {
try {
final String destResource =
- URLEncoder.encode(requestContext.getUriInfo().getRequestUri().toString(), "UTF-8");
+ URLEncoder.encode(requestContext.getUriInfo().getRequestUri().getPath(), "UTF-8");
final URI loginURI = requestContext.getUriInfo().getBaseUriBuilder()
.path(WebServerConstants.MAIN_LOGIN_RESOURCE_NAME)
.queryParam(WebServerConstants.REDIRECT_QUERY_PARM, destResource)
diff --git a/exec/java-exec/src/main/resources/rest/login.ftl b/exec/java-exec/src/main/resources/rest/login.ftl
index 790c93496..19cd12b8a 100644
--- a/exec/java-exec/src/main/resources/rest/login.ftl
+++ b/exec/java-exec/src/main/resources/rest/login.ftl
@@ -22,23 +22,22 @@
</#macro>
<#macro page_body>
- <div class="page-header"></div>
- <div align="center" class="table-responsive">
- <form role="form" name="input" action="/j_security_check" method="POST">
- <fieldset>
- <div class="form-group">
- <img src="/static/img/apache-drill-logo.png" alt="Apache Drill Logo">
- <#if model??>
- <p style="color:red">${model}</p></br>
- </#if>
- <h4>Log In to Drill Web Console</h4></br>
- <p><input type="text" size="30" name="j_username" placeholder="Username"></p>
- <p><input type="password" size="30" name="j_password" placeholder="Password"></p>
- <p><button type="submit" class="btn btn-default">Log In</button> </p>
- </div>
-
- </fieldset>
- </form>
- </div>
+ <div class="page-header"></div>
+ <div align="center" class="table-responsive">
+ <form role="form" name="input" action="/j_security_check" method="POST">
+ <fieldset>
+ <div class="form-group">
+ <img src="/static/img/apache-drill-logo.png" alt="Apache Drill Logo">
+ <#if model??>
+ <p style="color:red">${model}</p></br>
+ </#if>
+ <h4>Log In to Drill Web Console</h4></br>
+ <p><input type="text" size="30" name="j_username" placeholder="Username"></p>
+ <p><input type="password" size="30" name="j_password" placeholder="Password"></p>
+ <p><button type="submit" class="btn btn-default">Log In</button> </p>
+ </div>
+ </fieldset>
+ </form>
+ </div>
</#macro>
-<@page_html/> \ No newline at end of file
+<@page_html/>
diff --git a/exec/java-exec/src/main/resources/rest/mainLogin.ftl b/exec/java-exec/src/main/resources/rest/mainLogin.ftl
index 1e3a5a9a9..64f1fee89 100644
--- a/exec/java-exec/src/main/resources/rest/mainLogin.ftl
+++ b/exec/java-exec/src/main/resources/rest/mainLogin.ftl
@@ -22,20 +22,20 @@
</#macro>
<#macro page_body>
- <div class="page-header">
- </div>
- <div class="container container-table">
- <div align="center" class="table-responsive">
- <#if model?? && model.isFormEnabled()>
+ <div class="page-header">
+ </div>
+ <div class="container container-table">
+ <div align="center" class="table-responsive">
+ <#if model?? && model.isFormEnabled()>
<a href ="/login" class="btn btn-primary"> Login using FORM AUTHENTICATION </a>
- </#if>
- <#if model?? && model.isSpnegoEnabled()>
+ </#if>
+ <#if model?? && model.isSpnegoEnabled()>
<a href = "/spnegoLogin" class="btn btn-primary"> Login using SPNEGO </a>
- </#if>
- <#if model?? && model.getError()??>
+ </#if>
+ <#if model?? && model.getError()??>
<p style="color:red">${model.getError()}</p></br>
- </#if>
- </div>
- </div>
+ </#if>
+ </div>
+ </div>
</#macro>
-<@page_html/> \ No newline at end of file
+<@page_html/>