Lynicon can be configured like any other module or application in ASP.Net Core by changes to the Startup.cs file. The changes required to the different standard methods in the Startup class are listed below:
Constructor
public Startup(IHostingEnvironment env) { ... env.ConfigureLog4Net("log4net.xml"); }
The line shown above should be added at the end of the constructor for the Startup class to load the configuration for log4net, the logging system used by Lynicon.
public void ConfigureServices(IServiceCollection services) { ... services.AddIdentity<User, IdentityRole>() .AddDefaultTokenProviders(); services.AddMvc(options => options.AddLyniconOptions()) .AddApplicationPart(typeof(LyniconSystem).Assembly); services.AddAuthorization(options => options.AddLyniconAuthorization()); services.AddLynicon(options => options.UseConfiguration(Configuration.GetSection("Lynicon:Core")) .UseModule<CoreModule>() ) .AddLyniconIdentity(); }
The above 4 lines are additions or modifications of lines which may already be in Startup.cs according to how the site was set up or later configured.
- Ensure services.AddIdentity<,>() is called here. Don't use the configuration method AddEntityFrameworkStores<ApplicationDbContext>() as the appropriate entity framework stores for the user system are set up in the call to AddLyniconIdentity() later.
- Ensure AddMvc() is called here with the options lambda, calling at least AddLyniconOptions() to set up MVC for Lynicon. Call AddApplicationPart for all Lynicon assemblies in the project, at least the core Lynicon assembly.
- Ensure AddAuthorization() is called here with the options lambda, allowing you to call AddLyniconAuthorization to set up the default options for Lynicon authorization. See Custom Permissions for how to customise Lynicon's use of the Policy-based authorization in ASP.Net Core.
- Finally ensure .AddLynicon() is called to set up services for Lynicon itself.
0 Comments