Skip to content
Snippets Groups Projects
Commit 0d050f02 authored by Daniel Gerhardt's avatar Daniel Gerhardt
Browse files

Allow manually setting the API path for installations behind a proxy

parent 6ba81fca
No related merge requests found
...@@ -44,6 +44,9 @@ public class ConfigurationController extends AbstractController { ...@@ -44,6 +44,9 @@ public class ConfigurationController extends AbstractController {
public static final Logger LOGGER = LoggerFactory public static final Logger LOGGER = LoggerFactory
.getLogger(ConfigurationController.class); .getLogger(ConfigurationController.class);
@Value("${api.path:}")
private String apiPath;
@Value("${customization.path}") @Value("${customization.path}")
private String customizationPath; private String customizationPath;
...@@ -114,7 +117,10 @@ public class ConfigurationController extends AbstractController { ...@@ -114,7 +117,10 @@ public class ConfigurationController extends AbstractController {
HashMap<String, Boolean> features = new HashMap<String, Boolean>(); HashMap<String, Boolean> features = new HashMap<String, Boolean>();
/* The API path could be unknown to the client in case the request was forwarded */ /* The API path could be unknown to the client in case the request was forwarded */
config.put("apiPath", request.getContextPath()); if ("".equals(apiPath)) {
apiPath = request.getContextPath();
}
config.put("apiPath", apiPath);
if (!"".equals(customizationPath)) { if (!"".equals(customizationPath)) {
config.put("customizationPath", customizationPath); config.put("customizationPath", customizationPath);
......
...@@ -71,6 +71,7 @@ public class LoginController extends AbstractController { ...@@ -71,6 +71,7 @@ public class LoginController extends AbstractController {
private static final int MAX_USERNAME_LENGTH = 15; private static final int MAX_USERNAME_LENGTH = 15;
private static final int MAX_GUESTHASH_LENGTH = 10; private static final int MAX_GUESTHASH_LENGTH = 10;
@Value("${api.path:}") private String apiPath;
@Value("${customization.path}") private String customizationPath; @Value("${customization.path}") private String customizationPath;
@Value("${security.guest.enabled}") private String guestEnabled; @Value("${security.guest.enabled}") private String guestEnabled;
...@@ -285,7 +286,10 @@ public class LoginController extends AbstractController { ...@@ -285,7 +286,10 @@ public class LoginController extends AbstractController {
request.getSession().invalidate(); request.getSession().invalidate();
SecurityContextHolder.clearContext(); SecurityContextHolder.clearContext();
if (auth instanceof CasAuthenticationToken) { if (auth instanceof CasAuthenticationToken) {
return new RedirectView("/j_spring_cas_security_logout", true); if ("".equals(apiPath)) {
apiPath = request.getContextPath();
}
return new RedirectView(apiPath + "/j_spring_cas_security_logout", true);
} }
return new RedirectView(request.getHeader("referer") != null ? request.getHeader("referer") : "/"); return new RedirectView(request.getHeader("referer") != null ? request.getHeader("referer") : "/");
} }
...@@ -295,8 +299,11 @@ public class LoginController extends AbstractController { ...@@ -295,8 +299,11 @@ public class LoginController extends AbstractController {
public final List<ServiceDescription> getServices(final HttpServletRequest request) { public final List<ServiceDescription> getServices(final HttpServletRequest request) {
List<ServiceDescription> services = new ArrayList<ServiceDescription>(); List<ServiceDescription> services = new ArrayList<ServiceDescription>();
if ("".equals(apiPath)) {
apiPath = request.getContextPath();
}
/* The first parameter is replaced by the backend, the second one by the frondend */ /* The first parameter is replaced by the backend, the second one by the frondend */
String dialogUrl = request.getContextPath() + "/auth/dialog?type={0}&successurl='{0}'"; String dialogUrl = apiPath + "/auth/dialog?type={0}&successurl='{0}'";
if ("true".equals(guestEnabled)) { if ("true".equals(guestEnabled)) {
ServiceDescription sdesc = new ServiceDescription( ServiceDescription sdesc = new ServiceDescription(
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
# http://localhost:8080 for development. # http://localhost:8080 for development.
root-url=https://example.com root-url=https://example.com
# The path where the ARSnova API is accessible by clients. By default, this path
# is set to the context path of the backend. If you are running the backend
# behind a proxy server, you might need to set this path manually.
#api.path=/api
# The context paths where the ARSnova modules have been deployed # The context paths where the ARSnova modules have been deployed
customization.path=/customization customization.path=/customization
mobile.path=/mobile mobile.path=/mobile
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
# http://localhost:8080 for development. # http://localhost:8080 for development.
root-url=https://example.com root-url=https://example.com
# The path where the ARSnova API is accessible by clients. By default, this path
# is set to the context path of the backend. If you are running the backend
# behind a proxy server, you might need to set this path manually.
#api.path=/api
# The context paths where the ARSnova modules have been deployed # The context paths where the ARSnova modules have been deployed
customization.path=/customization customization.path=/customization
mobile.path=/mobile mobile.path=/mobile
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment