是否可以在不编辑 web.config 的情况下为 azure ACS 设置领域 URL、声明类型等?您能以某种方式以编程方式设置这些必需的元素吗?
编辑:
具体来说,我想摆脱这个:
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="true" issuer="https://mynamespace.accesscontrol.windows.net/v2/wsfederation" realm="http://localhost:81/" requireHttps="false" />
</federatedAuthentication>
基本上,我不希望在网络配置中指定领域,而是在某个地方的代码中指定领域。我尝试覆盖 ClaimsAuthenticationManager 并注释掉与 FederatedAuthentication 相关的代码部分。我的覆盖验证代码已被命中,但它不包含任何声明。我假设这是因为 FederatedAuthentication 是一个中介,它在正常到达重写的 ClaimsAuthenticationManager 之前执行自己的身份验证。有没有办法以类似的方式覆盖 FederatedAuthentication 部分?或者是否有信息传递到重写的身份验证方法中,我可以使用它来执行自己的身份验证?
为了从 Web 配置中删除该 xml 行,我创建了自己的 WSFederationAuthenticationModule 来覆盖旧的,如下所示:
public class CustomWSFederationAuthenticationModule : WSFederationAuthenticationModule
{
protected override void InitializePropertiesFromConfiguration(string serviceName)
{
this.Realm = "http://localhost:81/";
this.Issuer = "https://acsnamespace.accesscontrol.windows.net/v2/wsfederation";
this.RequireHttps = false;
this.PassiveRedirectEnabled = true;
}
}
web.config 的重要部分:
<modules runAllManagedModulesForAllRequests="true">
<add name="WSFederationAuthenticationModule" type="CustomModuleLocation.CustomWSFederationAuthenticationModule, CustomModuleLocation" preCondition="managedHandler"/>
<add name="SessionAuthenticationModule" type="Microsoft.IdentityModel.Web.SessionAuthenticationModule, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" />
</modules>
XML 的 federatedAuthentication 部分也被完全删除。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)