Skip to content

Commit 9db014d

Browse files
committed
refactor: relocate and refine passkey options configuration to application services extension
1 parent af5a527 commit 9db014d

2 files changed

Lines changed: 9 additions & 15 deletions

File tree

src/ApiService/BookStore.ApiService/Infrastructure/Extensions/ApplicationServicesExtensions.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,18 @@ static void AddIdentityServices(IServiceCollection services, IConfiguration conf
9898
options.Password.RequireNonAlphanumeric = true;
9999
options.Password.RequiredLength = 8;
100100

101-
// Passkey options
102-
var passkeyDomain = configuration["Authentication:Passkey:ServerDomain"];
103-
if (!string.IsNullOrEmpty(passkeyDomain))
104-
{
105-
options.Passkey.ServerDomain = passkeyDomain;
106-
}
107101
})
108102
.AddUserStore<Identity.MartenUserStore>();
109103

104+
// Configure Passkey options
105+
_ = services.Configure<Microsoft.AspNetCore.Identity.IdentityPasskeyOptions>(options =>
106+
{
107+
var passkeyDomain = configuration["Authentication:Passkey:ServerDomain"];
108+
options.ServerDomain = !string.IsNullOrEmpty(passkeyDomain) ? passkeyDomain : "localhost";
109+
options.AuthenticatorTimeout = TimeSpan.FromMinutes(2);
110+
options.ChallengeSize = 32;
111+
});
112+
110113
// Add roles support not needed via AddRoles (which requires IRoleStore),
111114
// as we use simple string roles on the user object via MartenUserStore implementation of IUserRoleStore.
112115

src/ApiService/BookStore.ApiService/Program.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@
4747
};
4848
});
4949

50-
// Configure passkey options (.NET 10 WebAuthn support)
51-
builder.Services.Configure<Microsoft.AspNetCore.Identity.IdentityPasskeyOptions>(options =>
52-
{
53-
var passkeyDomain = builder.Configuration["Authentication:Passkey:ServerDomain"] ?? "localhost";
54-
options.ServerDomain = passkeyDomain;
55-
options.AuthenticatorTimeout = TimeSpan.FromMinutes(2);
56-
options.ChallengeSize = 32;
57-
});
58-
5950
var app = builder.Build();
6051

6152
// Start seeding in the background (don't block app startup)

0 commit comments

Comments
 (0)