Merge pull request #3787 from pedroigor/KEYCLOAK-3261

[KEYCLOAK-3261] - Properly handle apps deployed at the ROOT context
This commit is contained in:
Stian Thorgersen 2017-01-24 08:37:40 +01:00 committed by GitHub
commit 04c4110f76
10 changed files with 48 additions and 2 deletions

View file

@ -253,8 +253,7 @@ public abstract class AbstractPolicyEnforcer {
}
private String getPath(Request request) {
String pathInfo = URI.create(request.getURI()).getPath().substring(1);
return pathInfo.substring(pathInfo.indexOf('/'), pathInfo.length());
return request.getRelativePath();
}
private Set<String> getRequiredScopes(PathConfig pathConfig, Request request) {

View file

@ -66,6 +66,11 @@ public class JaxrsHttpFacade implements OIDCHttpFacade {
return requestContext.getUriInfo().getRequestUri().toString();
}
@Override
public String getRelativePath() {
return requestContext.getUriInfo().getPath();
}
@Override
public boolean isSecure() {
return securityContext.isSecure();

View file

@ -218,6 +218,11 @@ public class ServletOAuthClient extends KeycloakDeploymentDelegateOAuthClient {
return servletRequest.getRequestURL().toString();
}
@Override
public String getRelativePath() {
return servletRequest.getServletPath();
}
@Override
public boolean isSecure() {
return servletRequest.isSecure();

View file

@ -70,6 +70,11 @@ class WrappedHttpServletRequest implements Request {
return buf.toString();
}
@Override
public String getRelativePath() {
return request.getServletPath();
}
@Override
public boolean isSecure() {
return request.isSecure();

View file

@ -43,6 +43,13 @@ public interface HttpFacade {
*/
String getURI();
/**
* Get the request relative path.
*
* @return the request relative path
*/
String getRelativePath();
/**
* HTTPS?
*

View file

@ -78,6 +78,11 @@ public class JettyHttpFacade implements HttpFacade {
return buf.toString();
}
@Override
public String getRelativePath() {
return request.getServletPath();
}
@Override
public String getFirstParam(String param) {
return request.getParameter(param);

View file

@ -65,6 +65,11 @@ public class ServletHttpFacade implements HttpFacade {
return buf.toString();
}
@Override
public String getRelativePath() {
return request.getServletPath();
}
@Override
public boolean isSecure() {
return request.isSecure();

View file

@ -78,6 +78,11 @@ public class CatalinaHttpFacade implements HttpFacade {
return buf.toString();
}
@Override
public String getRelativePath() {
return request.getServletPath();
}
@Override
public boolean isSecure() {
return request.isSecure();

View file

@ -83,6 +83,11 @@ public class UndertowHttpFacade implements HttpFacade {
return uriBuilder.build().toString();
}
@Override
public String getRelativePath() {
return exchange.getRelativePath();
}
@Override
public boolean isSecure() {
String protocol = exchange.getRequestScheme();

View file

@ -181,6 +181,11 @@ public class OfflineAccessPortalServlet extends HttpServlet {
return servletRequest.getRequestURL().toString();
}
@Override
public String getRelativePath() {
return servletRequest.getServletPath();
}
@Override
public boolean isSecure() {
return servletRequest.isSecure();