use of eu.openanalytics.shinyproxy.services.AppService.ShinyApp in project shinyproxy by openanalytics.
the class BaseController method getAppTitle.
protected String getAppTitle(HttpServletRequest request) {
String appName = getAppName(request);
if (appName == null || appName.isEmpty())
return "";
ShinyApp app = appService.getApp(appName);
if (app == null || app.getDisplayName() == null || app.getDisplayName().isEmpty())
return appName;
else
return app.getDisplayName();
}
use of eu.openanalytics.shinyproxy.services.AppService.ShinyApp in project shinyproxy by openanalytics.
the class IndexController method index.
@RequestMapping("/")
String index(ModelMap map, HttpServletRequest request) {
prepareMap(map, request);
List<ShinyApp> apps = userService.getAccessibleApps(SecurityContextHolder.getContext().getAuthentication());
map.put("apps", apps.toArray());
Map<ShinyApp, String> appLogos = new HashMap<>();
map.put("appLogos", appLogos);
boolean displayAppLogos = false;
for (ShinyApp app : apps) {
if (app.getLogoUrl() != null) {
displayAppLogos = true;
appLogos.put(app, resolveImageURI(app.getLogoUrl()));
}
}
map.put("displayAppLogos", displayAppLogos);
return "index";
}
use of eu.openanalytics.shinyproxy.services.AppService.ShinyApp in project shinyproxy by openanalytics.
the class WebSecurityConfig method configure.
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable().headers().frameOptions().disable();
if (auth.hasAuthorization()) {
// Limit access to the app pages
http.authorizeRequests().antMatchers("/login", "/signin/**", "/signup").permitAll();
for (ShinyApp app : appService.getApps()) {
String[] groups = app.getGroups();
if (groups == null || groups.length == 0)
continue;
String[] appGroups = Arrays.stream(groups).map(s -> s.toUpperCase()).toArray(i -> new String[i]);
http.authorizeRequests().antMatchers("/app/" + app.getName()).hasAnyRole(appGroups);
}
// Limit access to the admin pages
http.authorizeRequests().antMatchers("/admin").hasAnyRole(userService.getAdminGroups());
// All other pages are available to authenticated users
http.authorizeRequests().anyRequest().fullyAuthenticated();
http.formLogin().loginPage("/login").and().logout().logoutRequestMatcher(new AntPathRequestMatcher("/logout")).logoutSuccessHandler(logoutHandler).logoutSuccessUrl("/login");
}
auth.configureHttpSecurity(http);
}
use of eu.openanalytics.shinyproxy.services.AppService.ShinyApp in project shinyproxy by openanalytics.
the class ProxyService method startProxy.
private IContainerProxy startProxy(String userName, String appName) {
ShinyApp app = appService.getApp(appName);
if (app == null) {
throw new ShinyProxyException("Cannot start container: unknown application: " + appName);
}
if (findProxy(userName, appName) != null) {
throw new ShinyProxyException("Cannot start container: user " + userName + " already has an active proxy for " + appName);
}
ContainerProxyRequest request = new ContainerProxyRequest();
request.userId = userName;
request.app = app;
IContainerProxy proxy = backend.createProxy(request);
activeProxies.add(proxy);
try {
backend.startProxy(proxy);
} finally {
if (proxy.getStatus() != ContainerProxyStatus.Up)
activeProxies.remove(proxy);
}
try {
URI target = new URI(proxy.getTarget());
synchronized (mappingListeners) {
for (MappingListener listener : mappingListeners) {
listener.mappingAdded(proxy.getName(), target);
}
}
} catch (URISyntaxException ignore) {
}
if (logService.isContainerLoggingEnabled()) {
BiConsumer<File, File> outputAttacher = backend.getOutputAttacher(proxy);
if (outputAttacher == null) {
log.warn("Cannot log container output: " + backend.getClass() + " does not support output attaching.");
} else {
logService.attachToOutput(proxy, outputAttacher);
}
}
log.info(String.format("Proxy activated [user: %s] [app: %s]", userName, appName));
eventService.post(EventType.AppStart.toString(), userName, appName);
return proxy;
}
use of eu.openanalytics.shinyproxy.services.AppService.ShinyApp in project shinyproxy by openanalytics.
the class UserService method canAccess.
private boolean canAccess(Authentication principalAuth, String appName) {
ShinyApp app = appService.getApp(appName);
if (app == null)
return false;
String[] groups = app.getGroups();
if (groups == null || groups.length == 0)
return true;
if (principalAuth == null || principalAuth instanceof AnonymousAuthenticationToken)
return true;
for (String group : groups) {
if (isMember(principalAuth, group))
return true;
}
return false;
}
Aggregations