Skip to content

Admin dashboard

Mirko Da Corte edited this page Oct 22, 2020 · 1 revision

Here we assume that a working instance of MongODM on Asp.NET Core has already been configured. If not, you can start with this guide: Startup configuration.

Add packages

Administration dashbord is contained into the external optional package MongODM.AspNetCore.UI. You can install it with Package Manager Console or with your preferred project editor:

PM> Install-Package MongODM.AspNetCore.UI

Startup configuration

After have added the package we have to configure the dashboard registering components and options. On method ConfigureServices(IServiceCollection services) add this line of code:

services.AddMongODMAdminDashboard();

This method can also optionally take parameters, let see them next.

Last thing to be sure is that Asp.NET Core Authorization middleware is enabled. MongODM administration dashboard uses it for provide authorized access control. Verify that this line of code is reported in Configure(IApplicationBuilder app) method after the invoke app.UseRouting():

app.UseAuthorization();

Dashboard options

The method services.AddMongODMAdminDashboard() can take an optional configuration:

public class DashboardOptions
{
    public IEnumerable<IDashboardAuthFilter> AuthFilters { get; set; }
    public string BasePath { get; set; }
}
  • IEnumerable<IDashboardAuthFilter> AuthFilters
    This describe a list of authorization filters that have to be all satisfacted for permit user to access to dashboard pages. By default is setted only a filter that accept connections by localhost, but any IDashboardAuthFilter custom implementation can be provided
  • string BasePath
    It defines the base path for reach the dashboard pages, so for example if its value is "admin/dash", the dashboard Index page will be reachable at address https://<mysite.com>/admin/dash. By default its value is "MongODM"

Access filters

The interface IDashboardAuthFilter describes an authorization filter for Dashboard UI. It exposes only an async method Task<bool> AuthorizeAsync(HttpContext context) that receive an HttpContext of current request, and return true for authorization accepted, false otherwise.

Any provided filter during configuration has to be satisfacted for authorize user to access to the dashboard pages.

Features in dashboard

  • Every registered db context is showed separately
  • Can start migration for any database context
Clone this wiki locally