|
@@ -5,7 +5,6 @@ using Microsoft.AspNetCore.Mvc;
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
using Passwordless;
|
|
using Passwordless;
|
|
|
|
|
|
|
|
-// TODO: RoslynPad code for key generation
|
|
|
|
|
var jwk = JsonWebKey.Create(File.ReadAllText("./demo-jwk.json"));
|
|
var jwk = JsonWebKey.Create(File.ReadAllText("./demo-jwk.json"));
|
|
|
//var host = "http://localhost:5172";
|
|
//var host = "http://localhost:5172";
|
|
|
var host = "https://demo.larcanum.net";
|
|
var host = "https://demo.larcanum.net";
|
|
@@ -21,7 +20,7 @@ builder.Services.AddFido2(options =>
|
|
|
// server domain MUST match the actual domain name that the client uses to make the request from
|
|
// server domain MUST match the actual domain name that the client uses to make the request from
|
|
|
options.ServerDomain = host.Substring(host.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
|
options.ServerDomain = host.Substring(host.LastIndexOf("/", StringComparison.Ordinal) + 1);
|
|
|
options.ServerName = "FIDO2 Test";
|
|
options.ServerName = "FIDO2 Test";
|
|
|
- options.Origins = [host];
|
|
|
|
|
|
|
+ options.Origins = [host, "http://localhost:5172"];
|
|
|
options.TimestampDriftTolerance = 300000;
|
|
options.TimestampDriftTolerance = 300000;
|
|
|
});
|
|
});
|
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
@@ -44,7 +43,7 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
|
options.Authority = host;
|
|
options.Authority = host;
|
|
|
options.TokenValidationParameters = new TokenValidationParameters
|
|
options.TokenValidationParameters = new TokenValidationParameters
|
|
|
{
|
|
{
|
|
|
- IssuerSigningKey = jwk,
|
|
|
|
|
|
|
+ IssuerSigningKey = KeyConverter.ExtractPublicKey(jwk),
|
|
|
ValidIssuer = host,
|
|
ValidIssuer = host,
|
|
|
ValidAudience = host,
|
|
ValidAudience = host,
|
|
|
NameClaimType = ClaimTypes.NameIdentifier, // important to get the "sub" claim mapped to User.Identity.Name
|
|
NameClaimType = ClaimTypes.NameIdentifier, // important to get the "sub" claim mapped to User.Identity.Name
|