服务堆栈 APIKey
ServiceStack ApiKey
我正在为我的第一个 api 服务使用 serviceStack。
我有自己的 table“MyApiKeysTable”,我在其中为用户存储了多个 api 密钥。
我用 Entity Framework.
如果我使用 OrmLiteAuthRepository,它会创建自己的 api密钥 table。
我必须做什么才能使用我自己的 table "MyApiKeysTable"?
(我不想使用 OrmLite 但仍然继续使用 EntityFramework。)
有例子吗?
您不能使用自己的 ApiKey
类型,ServiceStack's API Key AuthProvider resolves its API Keys from Auth Repositories which implement the IManageApiKeys interface which all ServiceStack Auth Repositories 支持 API 密钥持久化工具。
您需要像 OrmLiteAuthRepository 一样创建您自己的 Auth 存储库并按照您的喜好实施 IManageApiKeys
,但它至少需要 return 一个 class继承了ApiKey
class。
实施您自己的 Auth Repository 需要相当多的努力,我不建议这样做,因为 OrmLite is a lightweight code-first POCO ORM that only needs its OrmLiteConnectionFactory 配置了数据库连接字符串,您仍然可以将 EF 用于应用程序的其余部分,但我将利用现有的 Auth 存储库。
另一种方法是忽略 ServiceStack 的 API Key Auth Provider 并实现您自己的使用您首选的数据访问库的方法,您可以使用 ApiKeyAuthProvider 实现作为指南。
我正在为我的第一个 api 服务使用 serviceStack。
我有自己的 table“MyApiKeysTable”,我在其中为用户存储了多个 api 密钥。 我用 Entity Framework.
如果我使用 OrmLiteAuthRepository,它会创建自己的 api密钥 table。
我必须做什么才能使用我自己的 table "MyApiKeysTable"?
(我不想使用 OrmLite 但仍然继续使用 EntityFramework。)
有例子吗?
您不能使用自己的 ApiKey
类型,ServiceStack's API Key AuthProvider resolves its API Keys from Auth Repositories which implement the IManageApiKeys interface which all ServiceStack Auth Repositories 支持 API 密钥持久化工具。
您需要像 OrmLiteAuthRepository 一样创建您自己的 Auth 存储库并按照您的喜好实施 IManageApiKeys
,但它至少需要 return 一个 class继承了ApiKey
class。
实施您自己的 Auth Repository 需要相当多的努力,我不建议这样做,因为 OrmLite is a lightweight code-first POCO ORM that only needs its OrmLiteConnectionFactory 配置了数据库连接字符串,您仍然可以将 EF 用于应用程序的其余部分,但我将利用现有的 Auth 存储库。
另一种方法是忽略 ServiceStack 的 API Key Auth Provider 并实现您自己的使用您首选的数据访问库的方法,您可以使用 ApiKeyAuthProvider 实现作为指南。