-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathStartup.cs
More file actions
77 lines (65 loc) · 2.52 KB
/
Startup.cs
File metadata and controls
77 lines (65 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
using IdentityServer4.Stores;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Configuration;
using OpenActive.FakeDatabase.NET;
using Microsoft.Extensions.Logging;
namespace IdentityServer
{
public class Startup
{
public IWebHostEnvironment Environment { get; }
public Startup(IWebHostEnvironment environment, IConfiguration configuration)
{
Environment = environment;
AppSettings = new AppSettings();
configuration.Bind(AppSettings);
}
public AppSettings AppSettings { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IClientStore, ClientStore>();
services.AddSingleton(x => new FakeBookingSystem
(
AppSettings.FeatureFlags.FacilityUseHasSlots,
x.GetRequiredService<ILogger<FakeBookingSystem>>()
));
var builder = services.AddIdentityServer(options =>
{
options.Discovery.CustomEntries.Add("registration_endpoint", "~/connect/register");
})
.AddInMemoryIdentityResources(Config.Ids)
.AddInMemoryApiScopes(Config.ApiScopes)
.AddInMemoryApiResources(Config.ApiResources)
.AddClientStore<ClientStore>()
.AddFakeUserStore(AppSettings.JsonLdIdBaseUrl)
.AddPersistedGrantStore<AcmePersistedGrantStore>();
services.AddControllersWithViews();
// not recommended for production - you need to store your key material somewhere secure
builder.AddDeveloperSigningCredential();
}
public void Configure(IApplicationBuilder app)
{
if (Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/error");
}
app.UseIdentityServer();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
});
}
}
}