-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
.NET Version: 10.0
SecurityKey Version: 4.0.0
I created a custom validator like in the documentation and added the following config to program.cs
builder.Services.AddScoped<IApiUserRepository, ApiUserRepository>();
builder.Services.AddSecurityKey<DatabaseSecurityKeyValidator>();
My implementation is almost 100% like in the example except it is called ApiUser instead of ApiKey. Once I run my program I get the following:
Unhandled exception. System.AggregateException: Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: AspNetCore.SecurityKey.ISecurityKeyValidator Lifetime: Singleton ImplementationType: Services.DatabaseSecurityKeyValidator': Cannot consume scoped service 'Interfaces.IApiUserRepository' from singleton 'AspNetCore.SecurityKey.ISecurityKeyValidator'.) (Error while validating the service descriptor 'ServiceType: AspNetCore.SecurityKey.SecurityKeyAuthorizationFilter Lifetime: Singleton ImplementationType: AspNetCore.SecurityKey.SecurityKeyAuthorizationFilter': Cannot consume scoped service 'Interfaces.IApiUserRepository' from singleton 'AspNetCore.SecurityKey.ISecurityKeyValidator'.) (Error while validating the service descriptor 'ServiceType: AspNetCore.SecurityKey.SecurityKeyAuthenticationHandler Lifetime: Transient ImplementationType: AspNetCore.SecurityKey.SecurityKeyAuthenticationHandler': Cannot consume scoped service 'Interfaces.IApiUserRepository' from singleton 'AspNetCore.SecurityKey.ISecurityKeyValidator'.)
Am I missing something?
BTW when I use AddSecurityKey without my own validator everything works as expected.