|
3 | 3 | using AutoMapper;
|
4 | 4 | using FluentValidation.AspNetCore;
|
5 | 5 | using MicroElements.Swashbuckle.FluentValidation;
|
| 6 | +using Microsoft.AspNetCore.Authentication.JwtBearer; |
6 | 7 | using Microsoft.AspNetCore.Builder;
|
7 | 8 | using Microsoft.AspNetCore.Hosting;
|
8 | 9 | using Microsoft.AspNetCore.Mvc;
|
@@ -35,6 +36,18 @@ public Startup(IHostEnvironment env, IConfiguration configuration)
|
35 | 36 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
36 | 37 | public void ConfigureServices(IServiceCollection services)
|
37 | 38 | {
|
| 39 | + var configSettings = _configuration.GetSection(nameof(ConfigurationSettings)).Get<ConfigurationSettings>(); |
| 40 | + |
| 41 | + services.AddAuthentication(options => |
| 42 | + { |
| 43 | + options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; |
| 44 | + options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; |
| 45 | + }).AddJwtBearer(options => |
| 46 | + { |
| 47 | + options.Authority = $"https://{configSettings.Auth0Authority}/"; |
| 48 | + options.Audience = configSettings.Auth0ApiIdentifier; |
| 49 | + }); |
| 50 | + |
38 | 51 | services.AddMvc(opts =>
|
39 | 52 | {
|
40 | 53 | // Define MediaType limits ...
|
@@ -75,7 +88,7 @@ public void ConfigureServices(IServiceCollection services)
|
75 | 88 |
|
76 | 89 | services.AddAdminAssistantServerSideProviders();
|
77 | 90 | services.AddAdminAssistantServerSideDomainModel();
|
78 |
| - services.AddAdminAssistantServerSideInfra(_configuration.GetSection(nameof(ConfigurationSettings)).Get<ConfigurationSettings>()); |
| 91 | + services.AddAdminAssistantServerSideInfra(configSettings); |
79 | 92 | }
|
80 | 93 |
|
81 | 94 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
@@ -105,9 +118,9 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
105 | 118 | app.UseHttpsRedirection();
|
106 | 119 | app.UseBlazorFrameworkFiles();
|
107 | 120 | app.UseStaticFiles();
|
108 |
| - |
109 | 121 | app.UseRouting();
|
110 |
| - |
| 122 | + app.UseAuthentication(); |
| 123 | + app.UseAuthorization(); |
111 | 124 | app.UseEndpoints(endpoints =>
|
112 | 125 | {
|
113 | 126 | endpoints.MapRazorPages();
|
|
0 commit comments