首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在多租户环境中配置IdentityServer4 ConfigurationStore和OperationalStore

在多租户环境中配置IdentityServer4 ConfigurationStore和OperationalStore
EN

Stack Overflow用户
提问于 2018-09-19 13:23:45
回答 1查看 194关注 0票数 3

我们有一个使用IdentityServer4进行身份验证的web。我试图通过保留现有的DB来更改身份验证服务,以支持多租户。因此,每个租户都有单独的DB。

我目前正在努力配置ConfigurationStore和OperationalStore。

选项01:由于每个租户都有单独的DB,所以可以将ConfigurationDb和PersistedGrantDb相关表添加到这些DB中。

选项02:使用公共DB保存与ConfigurationDb和PersistedGrantDb相关的表。

什么是最好的方法?

代码语言:javascript
复制
services.AddIdentityServer()
    // this adds the config data from DB (clients, resources, CORS)
    .AddConfigurationStore(options =>
    {
        options.ConfigureDbContext = builder =>
            builder.UseSqlServer(connectionString,
                sql => sql.MigrationsAssembly(migrationsAssembly));
    })
    .AddOperationalStore(options =>
    {
        options.ConfigureDbContext = builder =>
            builder.UseSqlServer(connectionString,
                sql => sql.MigrationsAssembly(migrationsAssembly));

        // this enables automatic token cleanup. this is optional.
        options.EnableTokenCleanup = true;
        options.TokenCleanupInterval = 30; // interval in seconds
    });
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-16 04:38:22

我们无法找到在单独的DB中配置ConfigurationStore和OperationalStore的方法。从那时起,我们已经在我们的公共DB中配置了它们。因此,最终的DB结构如下所示。

  • TenantDB:面向所有租户的通用DB。保存租户配置,如租户名称、主机/域详细信息、连接字符串。以及ConfigurationStore和OperationalStore配置。
  • Tenant01DB :租户01数据
  • Tenant02DB :租户02数据
  • Tenant03DB :租户03数据
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52406927

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档