-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
86 lines (65 loc) · 2.77 KB
/
Program.cs
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
78
79
80
81
82
83
84
85
86
using Algorand;
using Algorand.Algod;
using Algorand.KMD;
using Fido2NetLib;
namespace AlgorandAuth
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddRazorPages();
// Use the in-memory implementation of IDistributedCache.
builder.Services.AddMemoryCache();
builder.Services.AddDistributedMemoryCache();
builder.Services.AddSession(options =>
{
// Set a short timeout for easy testing.
options.IdleTimeout = TimeSpan.FromMinutes(2);
options.Cookie.HttpOnly = true;
// Strict SameSite mode is required because the default mode used
// by ASP.NET Core 3 isn't understood by the Conformance Tool
// and breaks conformance testing
options.Cookie.SameSite = SameSiteMode.Unspecified;
});
builder.Configuration
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddEnvironmentVariables();
// Use the configuration
var configuration = builder.Configuration;
builder.Services.AddFido2(options =>
{
options.ServerDomain = configuration["fido2:serverDomain"];
options.ServerName = "FIDO2 Test";
options.Origins = configuration.GetSection("fido2:origins").Get<HashSet<string>>();
options.TimestampDriftTolerance = configuration.GetValue<int>("fido2:timestampDriftTolerance");
options.MDSCacheDirPath = configuration["fido2:MDSCacheDirPath"];
})
.AddCachedMetadataService(config =>
{
config.AddFidoMetadataRepository(httpClientBuilder =>
{
//TODO: any specific config you want for accessing the MDS
});
});
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseSession();
app.UseRouting();
app.UseAuthorization();
app.MapRazorPages();
app.Run();
}
}
}