Skip to content

Commit ca624e3

Browse files
committed
issues/269 redirect user to first available app when proxy.landing-page=auto
Allows ShinyProxy to use the first available app for a logged-in user as landing page, bypassing the built-in index page. This can be used when different permissions for different users makes it impractical to identify an app which is accessible by all users in the system and usable as predefined landing page/app.
1 parent 5ac010e commit ca624e3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/main/java/eu/openanalytics/shinyproxy/controllers/IndexController.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
@Controller
4242
public class IndexController extends BaseController {
4343

44+
private static final String PROXY_LANDING_PAGE_AUTO_OPTION = "auto";
45+
4446
@Inject
4547
private ShinyProxySpecProvider shinyProxySpecProvider;
4648

@@ -57,13 +59,20 @@ public void init() {
5759
@RequestMapping("/")
5860
private Object index(ModelMap map, HttpServletRequest request) {
5961
String landingPage = environment.getProperty("proxy.landing-page", "/");
60-
if (!landingPage.equals("/")) return new RedirectView(landingPage);
62+
if (!landingPage.equals("/") && !landingPage.equals(PROXY_LANDING_PAGE_AUTO_OPTION)) {
63+
return new RedirectView(landingPage);
64+
}
6165

6266
prepareMap(map, request);
6367

6468
ProxySpec[] apps = proxyService.getProxySpecs(null, false).toArray(new ProxySpec[0]);
6569
map.put("apps", apps);
6670

71+
// If set to `auto`, redirect to the first available app in the list
72+
// See https://github.com/openanalytics/shinyproxy/issues/269
73+
if (apps.length > 0 && landingPage.equals(PROXY_LANDING_PAGE_AUTO_OPTION))
74+
return new RedirectView("/app/" + apps[0].getId());
75+
6776
Map<ProxySpec, String> appLogos = new HashMap<>();
6877
map.put("appLogos", appLogos);
6978

0 commit comments

Comments
 (0)