You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.4 KiB
70 lines
2.4 KiB
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using System.IdentityModel.Tokens.Jwt;
|
|
|
|
namespace Results
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddAuthorization(o => o.FallbackPolicy = o.DefaultPolicy);
|
|
services.AddRazorPages();
|
|
services.AddServerSideBlazor();
|
|
|
|
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
|
|
|
|
services.AddAuthentication(options =>
|
|
{
|
|
options.DefaultScheme = "Cookies";
|
|
options.DefaultChallengeScheme = "oidc";
|
|
})
|
|
.AddCookie("Cookies")
|
|
.AddOpenIdConnect("oidc", options =>
|
|
{
|
|
options.Authority = Configuration.GetServiceUri("identityserver:https").AbsoluteUri;
|
|
options.ClientId = "interactive";
|
|
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";
|
|
options.ResponseType = "code";
|
|
options.SaveTokens = true;
|
|
});
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
else
|
|
{
|
|
app.UseExceptionHandler("/Error");
|
|
}
|
|
|
|
app.UseStaticFiles();
|
|
|
|
app.UseRouting();
|
|
app.UseAuthentication();
|
|
app.UseAuthorization();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapBlazorHub().RequireAuthorization();
|
|
endpoints.MapFallbackToPage("/_Host");
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|