layout: docs-default
客户端和作用域
存储
客户端存储
ClientStore 基于EF实现了 IClientStore 接口. 它可以独立于ScopeStore来使用.
作用域存储
ScopeStore基于EF实现了IScopeStore 接口.它可以独立于ClientStore来使用.
注册
使用上述存储前需要在IdentityServerServiceFactory 里面注册。所有的扩展方法接受 EntityFrameworkServiceOptions 参数,它具有下面属性:
-
ConnectionString: 连接字符串的名字,配置在.config文件中. -
Schema: 可选的数据库schema,如果没有提供,那么使用数据库默认schema(一般是dbo.)
分别配置这两个存储的代码如下:
var efConfig = new EntityFrameworkServiceOptions {
ConnectionString = "SomeConnectionName",
//Schema = "someSchemaIfDesired"
};
var factory = new IdentityServerServiceFactory();
factory.RegisterClientStore(efConfig);
factory.RegisterScopeStore(efConfig);
如果两个存储使用相同的 EntityFrameworkServiceOptions, 那么可以使用一个简化的方法来注册:
var efConfig = new EntityFrameworkServiceOptions {
ConnectionString = "SomeConnectionName",
//Schema = "someSchemaIfDesired"
};
var factory = new IdentityServerServiceFactory();
factory.RegisterConfigurationServices(efConfig);









网友评论