是否可以在不编辑web.config的情况下获得ACS声明?

Set*_*zzi 8 c# azure claims-based-identity wif acs

是否可以在不编辑web.config的情况下为azure ACS设置领域URL,声明类型等?你能以某种方式以编程方式设置这些必需的元素吗?

编辑:具体我想摆脱这个:

<federatedAuthentication>
    <wsFederation passiveRedirectEnabled="true" issuer="https://mynamespace.accesscontrol.windows.net/v2/wsfederation" realm="http://localhost:81/" requireHttps="false" />
</federatedAuthentication>
Run Code Online (Sandbox Code Playgroud)

基本上,我不希望在Web配置中指定域,而是在代码中指定.我已经尝试重写ClaimsAuthenticationManager并将部分注释到与FederatedAuthentication相关的代码中.我的被​​覆盖的身份验证代码被命中,但它不包含任何声明.我假设这是因为FederatedAuthentication是一个中介,它在正常访问被覆盖的ClaimsAuthenticationManager之前执行自己的身份验证.有没有办法以类似的方式覆盖FederatedAuthentication部分?或者是否有信息传递到我可以用来执行我自己的身份验证的重写的身份验证方法?

Set*_*zzi 10

要从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;
    }
}
Run Code Online (Sandbox Code Playgroud)

而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>
Run Code Online (Sandbox Code Playgroud)

此外,XML的federatedAuthentication部分也完全删除.