|
@@ -7,6 +7,8 @@ using Passwordless;
|
|
|
|
|
|
|
|
// TODO: RoslynPad code for key generation
|
|
// 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 = "https://demo.larcanum.net";
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
@@ -16,9 +18,10 @@ builder.Services.AddEndpointsApiExplorer();
|
|
|
builder.Services.AddSwaggerGen();
|
|
builder.Services.AddSwaggerGen();
|
|
|
builder.Services.AddFido2(options =>
|
|
builder.Services.AddFido2(options =>
|
|
|
{
|
|
{
|
|
|
- options.ServerDomain = "localhost";
|
|
|
|
|
|
|
+ // 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.ServerName = "FIDO2 Test";
|
|
options.ServerName = "FIDO2 Test";
|
|
|
- options.Origins = ["http://localhost:5172"];
|
|
|
|
|
|
|
+ options.Origins = [host];
|
|
|
options.TimestampDriftTolerance = 300000;
|
|
options.TimestampDriftTolerance = 300000;
|
|
|
});
|
|
});
|
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
@@ -38,12 +41,12 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
options.RequireHttpsMetadata = false; // dev only!!!
|
|
options.RequireHttpsMetadata = false; // dev only!!!
|
|
|
- options.Authority = "http://localhost:5172";
|
|
|
|
|
|
|
+ options.Authority = host;
|
|
|
options.TokenValidationParameters = new TokenValidationParameters
|
|
options.TokenValidationParameters = new TokenValidationParameters
|
|
|
{
|
|
{
|
|
|
IssuerSigningKey = jwk,
|
|
IssuerSigningKey = jwk,
|
|
|
- ValidIssuer = "http://localhost:5172",
|
|
|
|
|
- ValidAudience = "http://localhost:5172",
|
|
|
|
|
|
|
+ ValidIssuer = 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
|
|
|
RoleClaimType = ClaimTypes.Role,
|
|
RoleClaimType = ClaimTypes.Role,
|
|
|
};
|
|
};
|
|
@@ -56,7 +59,11 @@ builder.Services.AddAuthorization(authorizationOptions =>
|
|
|
.RequireRole("grunt"));
|
|
.RequireRole("grunt"));
|
|
|
});
|
|
});
|
|
|
builder.Services.AddMemoryCache();
|
|
builder.Services.AddMemoryCache();
|
|
|
-builder.Services.Configure<JwtConfig>(config => config.Key = jwk);
|
|
|
|
|
|
|
+builder.Services.Configure<JwtConfig>(config =>
|
|
|
|
|
+{
|
|
|
|
|
+ config.Key = jwk;
|
|
|
|
|
+ config.Host = host;
|
|
|
|
|
+});
|
|
|
builder.Services.AddTransient<OptionsCache>();
|
|
builder.Services.AddTransient<OptionsCache>();
|
|
|
builder.Services.AddTransient<CredentialManager>();
|
|
builder.Services.AddTransient<CredentialManager>();
|
|
|
|
|
|