简体   繁体   English

在没有web.config的情况下使用WIF

[英]Using WIF without web.config

I need to create a web application that uses WIF to communicate with ADFS in order to login users. 我需要创建一个使用WIF与ADFS进行通信的Web应用程序,以便登录用户。 This web application supports multi-tenancy, accordingly, the same code base will be used to serve requests to site1.mydomain.com and site2.mydomain.com . 此Web应用程序支持多租户,因此,将使用相同的代码库处理对site1.mydomain.comsite2.mydomain.com请求。

Currently, my WIF configuration is in the web.config file which is preventing me from achieving multi-tenancy. 目前,我的WIF配置位于web.config文件中,这使我无法实现多租户。 So I thought maybe there's a way to provide all the required WIF configuration through code by reading the host name from the request url and retrieving the tenant's configuration from the database instead of the web.config file. 因此,我认为也许有一种方法可以通过代码提供所有必需的WIF配置,方法是从请求url中读取主机名,然后从数据库而不是从web.config文件中检索租户的配置。

Is that even possible? 那有可能吗? Any ideas or thoughts? 有什么想法或想法吗?

You migth get some ideas from this similar post : how do i move federated configuration out of the web config 您会从类似的帖子中得到一些想法: 如何将联合配置移出Web配置

AFAIK the FederationConfigurationCreated is called only once per application. AFAIK FederationConfigurationCreated每个应用程序仅被调用一次。 This means that you will need to "wire" things like a custom securitytokenhandler, cookiehandler, certificatvalidator etc that do their work based on the current context. 这意味着您将需要“连接”诸如自定义securitytokenhandler,cookiehandler,certificatvalidator等之类的东西,这些东西将基于当前上下文来工作。 I would personally consider all of this "doable" but it migth take you 1 to 2 months to get all the sharp edges out of it. 我个人会考虑所有这些“可行的”方法,但是要花上一到两个月的时间才能消除所有的尖锐边缘。 I mean, writing a securitytokenhandler is doable but it will be simpler when you have done so before. 我的意思是,写一个securitytokenhandler是可行的,但是如果您之前做过,那会更简单。 You will need to dive really deep in WIF and want to consider whether that is what you want. 您将需要深入了解WIF,并考虑是否要这样做。

As an alternative (that you probably don't want) you migth consider a deployment per tenant. 作为一种替代方法(您可能不希望这样做),您可以迁移考虑每个租户的部署。 Depending on the number and volatility of tenants this migth or migth not be a good idea. 根据租户的数量和波动性,这种迁移或迁移不是一个好主意。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM