Redirect to login from new Admin UI app
parent
fa7a74080d
commit
a7e02d61b1
|
|
@ -26,9 +26,7 @@ import freemarker.template.Configuration;
|
|||
import freemarker.template.Template;
|
||||
import freemarker.template.TemplateException;
|
||||
import freemarker.template.TemplateExceptionHandler;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
import org.libreccm.security.Shiro;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
|
@ -44,9 +42,11 @@ import javax.ws.rs.NotFoundException;
|
|||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.RedirectionException;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriBuilder;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -62,6 +62,9 @@ public class AdminUi {
|
|||
@Inject
|
||||
private ServletContext servletContext;
|
||||
|
||||
@Inject
|
||||
private Shiro shiro;
|
||||
|
||||
private Configuration configuration;
|
||||
|
||||
@PostConstruct
|
||||
|
|
@ -89,8 +92,8 @@ public class AdminUi {
|
|||
@GET
|
||||
@Path("/")
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
// @AuthorizationRequired
|
||||
// @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
public String getDashboard() {
|
||||
return getApp("dashboard");
|
||||
}
|
||||
|
|
@ -98,9 +101,21 @@ public class AdminUi {
|
|||
@GET
|
||||
@Path("/{appName}")
|
||||
@Produces(MediaType.TEXT_HTML)
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
// @AuthorizationRequired
|
||||
// @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
public String getApp(@PathParam("appName") final String appName) {
|
||||
if (!shiro.getUser().isPresent()
|
||||
|| !shiro.getSubject().isAuthenticated()) {
|
||||
final UriBuilder uriBuilder = UriBuilder.fromUri("/ccm/register");
|
||||
uriBuilder.queryParam(
|
||||
"return_url",
|
||||
String.format("%s/@admin", servletContext.getContextPath())
|
||||
);
|
||||
throw new RedirectionException(
|
||||
Response.Status.TEMPORARY_REDIRECT, uriBuilder.build()
|
||||
);
|
||||
}
|
||||
|
||||
final AdminUiApp app = adminUiApps
|
||||
.getAdminUiApp(appName)
|
||||
.orElseThrow(
|
||||
|
|
@ -125,6 +140,7 @@ public class AdminUi {
|
|||
final Map<String, Object> data = new HashMap<>();
|
||||
data.put("adminUiApps", adminUiApps.getAdminUiApps());
|
||||
data.put("activeApp", app);
|
||||
data.put("currentUser", shiro.getUser().get());
|
||||
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
# License along with this library; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
# MA 02110-1301 USA
|
||||
|
||||
dashboard.label=Dashboard
|
||||
dashboard.description=Dashboard
|
||||
systeminformation.label=System Information
|
||||
systeminformation.description=Shows several system properties
|
||||
|
|
@ -16,4 +16,6 @@
|
|||
# MA 02110-1301 USA
|
||||
|
||||
systeminformation.label=System Informationen
|
||||
systeminformation.description=Zeigt verschiedene Eigenschaften des Systems
|
||||
systeminformation.description=Zeigt verschiedene Eigenschaften des Systems
|
||||
dashboard.label=\u00dcbersicht
|
||||
dashboard.description=\u00dcbersicht
|
||||
|
|
|
|||
|
|
@ -5,9 +5,55 @@
|
|||
</head>
|
||||
<body>
|
||||
<h1>Admin UI</h1>
|
||||
<p>
|
||||
Current user ${currentUser.name}
|
||||
</p>
|
||||
<ul>
|
||||
<#list adminUiApps as app>
|
||||
<li>${app.name}</li>
|
||||
<li>
|
||||
<dl>
|
||||
<dt>Name</dt>
|
||||
<dd>${app.name}</dd>
|
||||
<dt>Label</dt>
|
||||
<dd>${app.label}</dd>
|
||||
<dt>Description</dt>
|
||||
<dd>${app.description}</dd>
|
||||
<dt>Order</dt>
|
||||
<dd>${app.order}</dd>
|
||||
<dt>JavascriptFiles</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<#list app.jsFilesUrls as jsFile>
|
||||
<li>${jsFile}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>CssFiles</dt>
|
||||
<dd>
|
||||
<ul>
|
||||
<#list app.cssFilesUrls as cssFile>
|
||||
<li>${cssFile}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>Icon Name</dt>
|
||||
<dd>
|
||||
<#if (app.iconName.isPresent())>
|
||||
${app.iconName.get()}
|
||||
<#else>
|
||||
n/a
|
||||
</#if>
|
||||
</dd>
|
||||
<dt>Symbol URL</dt>
|
||||
<dd>
|
||||
<#if (app.symbolUrl.isPresent())>
|
||||
${app.symbolUrl.get()}
|
||||
<#else>
|
||||
n/a
|
||||
</#if>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</body>
|
||||
|
|
|
|||
Loading…
Reference in New Issue