diff --git a/src/main/java/de/thm/arsnova/controller/ConfigurationController.java b/src/main/java/de/thm/arsnova/controller/ConfigurationController.java index 0fe5a45ce01d3283879138ff6012b2873e2f3114..badd966a5476c3c0c06d72e8c88425e1525e81a6 100644 --- a/src/main/java/de/thm/arsnova/controller/ConfigurationController.java +++ b/src/main/java/de/thm/arsnova/controller/ConfigurationController.java @@ -44,6 +44,9 @@ public class ConfigurationController extends AbstractController { public static final Logger LOGGER = LoggerFactory .getLogger(ConfigurationController.class); + @Value("${api.path:}") + private String apiPath; + @Value("${customization.path}") private String customizationPath; @@ -114,7 +117,10 @@ public class ConfigurationController extends AbstractController { HashMap<String, Boolean> features = new HashMap<String, Boolean>(); /* 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)) { config.put("customizationPath", customizationPath); diff --git a/src/main/java/de/thm/arsnova/controller/LoginController.java b/src/main/java/de/thm/arsnova/controller/LoginController.java index 8541728e2c8b694c46100130e94a312ff8a60e4a..27588e20a3cc2293d91293de1994b3d713a6c1f6 100644 --- a/src/main/java/de/thm/arsnova/controller/LoginController.java +++ b/src/main/java/de/thm/arsnova/controller/LoginController.java @@ -71,6 +71,7 @@ public class LoginController extends AbstractController { private static final int MAX_USERNAME_LENGTH = 15; private static final int MAX_GUESTHASH_LENGTH = 10; + @Value("${api.path:}") private String apiPath; @Value("${customization.path}") private String customizationPath; @Value("${security.guest.enabled}") private String guestEnabled; @@ -285,7 +286,10 @@ public class LoginController extends AbstractController { request.getSession().invalidate(); SecurityContextHolder.clearContext(); 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") : "/"); } @@ -295,8 +299,11 @@ public class LoginController extends AbstractController { public final List<ServiceDescription> getServices(final HttpServletRequest request) { 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 */ - String dialogUrl = request.getContextPath() + "/auth/dialog?type={0}&successurl='{0}'"; + String dialogUrl = apiPath + "/auth/dialog?type={0}&successurl='{0}'"; if ("true".equals(guestEnabled)) { ServiceDescription sdesc = new ServiceDescription( diff --git a/src/main/resources/arsnova.properties.example b/src/main/resources/arsnova.properties.example index e1cbb2293b5645299159484c0afb056e6f1a59a4..9cfaa64b1df53c856b1a7ead2f4d8bedbcb3b5ca 100644 --- a/src/main/resources/arsnova.properties.example +++ b/src/main/resources/arsnova.properties.example @@ -5,6 +5,11 @@ # http://localhost:8080 for development. 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 customization.path=/customization mobile.path=/mobile diff --git a/src/test/resources/arsnova.properties.example b/src/test/resources/arsnova.properties.example index e1cbb2293b5645299159484c0afb056e6f1a59a4..9cfaa64b1df53c856b1a7ead2f4d8bedbcb3b5ca 100644 --- a/src/test/resources/arsnova.properties.example +++ b/src/test/resources/arsnova.properties.example @@ -5,6 +5,11 @@ # http://localhost:8080 for development. 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 customization.path=/customization mobile.path=/mobile