Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将MVC5 ADF转换为.net核心ADF_C#_Asp.net Mvc_Authentication_.net Core_Adfs - Fatal编程技术网

C# 将MVC5 ADF转换为.net核心ADF

C# 将MVC5 ADF转换为.net核心ADF,c#,asp.net-mvc,authentication,.net-core,adfs,C#,Asp.net Mvc,Authentication,.net Core,Adfs,我有一个现有的MVC5应用程序,它成功地使用了内部部署的active directory联合服务 相关web配置设置 <appSettings> <add key="ida:Issuer" value="https://www.fedsvc3copa.beta.pa.gov/adfs/ls/"/> </appSettings> <authority name="http://www.fedsvc3copa.beta.pa.gov/adf

我有一个现有的MVC5应用程序,它成功地使用了内部部署的active directory联合服务

相关web配置设置

 <appSettings>
    <add key="ida:Issuer" value="https://www.fedsvc3copa.beta.pa.gov/adfs/ls/"/>
  </appSettings>

 <authority name="http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust">
          <keys>
            <add thumbprint="xxxxxxxxxxxxxxx"/>
          </keys>
          <validIssuers>
            <add name="http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust"/>
          </validIssuers>
        </authority>

           <federationConfiguration>
      <cookieHandler requireSsl="true"/>

      <wsFederation passiveRedirectEnabled="true" issuer="https://www.fedsvc3copa.beta.pa.gov/adfs/ls/" realm="https://localhost:44363/" requireHttps="true"/>
    </federationConfiguration>

我不确定要在AAD领域中放置什么,因为我没有使用azure。我不需要指纹和发卡机构吗

要回答您的第一个问题:

如果您不使用Azure,则不需要担心AAD。事实上,您希望确保
.Wtrealm
没有配置两次。所以只需移除第二个

要回答关于指纹和发卡机构的第二个问题:

我认为您不需要这些值,但考虑到指纹和颁发者值用于验证令牌,它们可能很好

我尝试在下面的代码中复制所有原始配置设置,这些设置属于
startup.cs
文件。可以从MetadataAddressURL处的xml文件中检索x.509证书字符串的
值。它将位于
标记之间

var rawCertData = Convert.FromBase64String("your x.509 cert string");
X509Certificate2 cert = new X509Certificate2(rawCertData);
SecurityKey signingKey = new X509SecurityKey(cert);
    services.AddAuthentication()
        .AddWsFederation(options => {
            options.MetadataAddress = "https://www.fedsvc3copa.beta.pa.gov/federationmetadata/2007-06/FederationMetadata.xml";
            options.Wtrealm = "https://localhost:44363/";
            options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters {
                ValidateIssuer = true,
                ValidIssuer = "http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust",
                ValidateIssuerSigningKey = true,
                IssuerSigningKey = signingKey
            };
            options.RequireHttpsMetadata = true;
        }).AddCookie(cookieoption => {
            cookieoption.Cookie.SecurePolicy = CookieSecurePolicy.Always;
        });

注意:通过此配置,我可以进入您的adfs登录页面。但是,我无法登录,因为我没有权限;所以我不知道你登录后会发生什么。如果您有问题,请随时告诉我。

您不需要最后一个属性中的任何内容,即您填写的
。文档显示了两种不同的方式,请注意,属性名称与其上方的名称相同。第一个
.Wtrealm
示例用于ADF,第二个用于AAD。只需拆下第二个。我不熟悉这个特定的Active Directory设置,只是从文档中注意到。是的,我试过了,它带我到orgs登录页面,但我得到了一个错误发生了一个错误。有关详细信息,请与管理员联系。错误详细信息活动ID:c2667d30-335f-4da5-6b0a-0080010000e4错误时间:2019年5月6日星期一17:32:05 GMT Cookie:启用的用户代理字符串:Mozilla/5.0(Windows NT 10.0;Win64;x64)AppleWebKit/537.36(KHTML,如Gecko)Chrome/74.0.3729.131 Safari/537.36
var rawCertData = Convert.FromBase64String("your x.509 cert string");
X509Certificate2 cert = new X509Certificate2(rawCertData);
SecurityKey signingKey = new X509SecurityKey(cert);
    services.AddAuthentication()
        .AddWsFederation(options => {
            options.MetadataAddress = "https://www.fedsvc3copa.beta.pa.gov/federationmetadata/2007-06/FederationMetadata.xml";
            options.Wtrealm = "https://localhost:44363/";
            options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters {
                ValidateIssuer = true,
                ValidIssuer = "http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust",
                ValidateIssuerSigningKey = true,
                IssuerSigningKey = signingKey
            };
            options.RequireHttpsMetadata = true;
        }).AddCookie(cookieoption => {
            cookieoption.Cookie.SecurePolicy = CookieSecurePolicy.Always;
        });