|
@@ -1,4 +1,8 @@
|
|
|
|
|
+using System.Text;
|
|
|
using Fido2NetLib;
|
|
using Fido2NetLib;
|
|
|
|
|
+using Fido2NetLib.Objects;
|
|
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
+using Passwordless;
|
|
|
|
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
|
|
|
@@ -26,16 +30,34 @@ if (app.Environment.IsDevelopment())
|
|
|
app.UseStaticFiles();
|
|
app.UseStaticFiles();
|
|
|
app.UseHttpsRedirection();
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
-var summaries = new[]
|
|
|
|
|
-{
|
|
|
|
|
- "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-app.MapGet("/buildCredentialOptions", (IFido2 fido2) =>
|
|
|
|
|
|
|
+app.MapGet("/buildCredentialOptions", ([FromQuery] string login, IFido2 fido2) =>
|
|
|
{
|
|
{
|
|
|
var data = File.ReadAllText("./data/test.json");
|
|
var data = File.ReadAllText("./data/test.json");
|
|
|
- return data;
|
|
|
|
|
|
|
+ var loginDisplay = Encoding.UTF8.GetString(Convert.FromBase64String(login));
|
|
|
|
|
+ var loginName = NameTransform.ToFileName(loginDisplay);
|
|
|
|
|
+
|
|
|
|
|
+ var user = new Fido2User
|
|
|
|
|
+ {
|
|
|
|
|
+ DisplayName = loginDisplay,
|
|
|
|
|
+ Id = Convert.FromBase64String(login),
|
|
|
|
|
+ Name = loginName,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ var authenticatorSelection = new AuthenticatorSelection
|
|
|
|
|
+ {
|
|
|
|
|
+ UserVerification = UserVerificationRequirement.Discouraged,
|
|
|
|
|
+ RequireResidentKey = false,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ var extensions = new AuthenticationExtensionsClientInputs
|
|
|
|
|
+ {
|
|
|
|
|
+ Extensions = true,
|
|
|
|
|
+ UserVerificationMethod = false,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ var options = fido2.RequestNewCredential(user, new List<PublicKeyCredentialDescriptor>(), authenticatorSelection, AttestationConveyancePreference.None, extensions);
|
|
|
|
|
+
|
|
|
|
|
+ return options;
|
|
|
})
|
|
})
|
|
|
.WithName("BuildCredentialOptions")
|
|
.WithName("BuildCredentialOptions")
|
|
|
.WithOpenApi();
|
|
.WithOpenApi();
|