这是我的身份验证配置
Plugins.Add(new AuthFeature(() => new AuthUserSession(), new IAuthProvider[] {
new ApiKeyAuthProvider(AppSettings) { RequireSecureConnection = false, InitSchema = true},
new CredentialsAuthProvider(AppSettings)
})
{
IncludeRegistrationService = true,
});
container.Register<IAuthRepository>(c => new OrmLiteAuthRepository(dbFactory));
container.Resolve<IAuthRepository>().InitSchema();
当我尝试在服务中解决IManageApiKeys的依赖关系时,它会抛出异常无法转换类型&#39; ServiceStack.Auth.OrmLiteAuthRepository&#39;的对象。输入&#39; ServiceStack.Auth.IManageApiKeys
var apiRepo = (IManageApiKeys)base.TryResolve<IAuthRepository>();
我无法弄清楚如何解决IManageApiKeys的依赖关系,并且它不会通过InitSchema()创建ApiKey表,但会创建UserAuth,UserAuthDetails和UserAuthRole。
答案 0 :(得分:2)
OrmLiteAuthRepository does implement IManageApiKeys所以我假设您在 ServiceStack.Server NuGet包中的OrmLiteAuthRepository
版本与版本相同 ServiceStack NuGet包。
检查您的/packages
文件夹,并确保每个ServiceStack依赖项引用相同的版本号,如果有不同的版本升级每个项目,那么它们都引用相同的版本。