首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将mvc 5 adfs转换为.net核心adfs

将mvc 5 adfs转换为.net核心adfs
EN

Stack Overflow用户
提问于 2019-05-02 19:03:37
回答 1查看 1.8K关注 0票数 4

我有一个现有的mvc 5应用程序,它成功地在前提活动目录联邦服务上使用。

相关的web配置设置

代码语言:javascript
复制
 <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>

试图为.net核心mvc应用程序做同样的事情。但我有点搞不懂在startup.cs里放什么

我和https://learn.microsoft.com/en-us/aspnet/core/security/authentication/ws-federation?view=aspnetcore-2.1一起跟进

所以我有

代码语言:javascript
复制
 .AddWsFederation(options =>
      {
        // MetadataAddress represents the Active Directory instance used to authenticate users.
        options.MetadataAddress = "https://www.fedsvc3copa.beta.pa.gov/federationmetadata/2007-06/FederationMetadata.xml";

        // Wtrealm is the app's identifier in the Active Directory instance.
        // For ADFS, use the relying party's identifier, its WS-Federation Passive protocol URL:
        options.Wtrealm = "https://localhost:44363/";

        // For AAD, use the App ID URI from the app registration's Properties blade:
        options.Wtrealm = "???????";
      });

我不知道把什么放在AAD领域,因为我没有使用天蓝色。另外,我不需要指纹和发行者吗?http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-11 01:31:51

要回答你的第一个问题:

如果您不使用Azure,则不需要担心AAD。实际上,您希望确保.Wtrealm不会被配置两次。所以把第二个就行了。

要回答关于拇指指纹和颁发者的第二个问题:

我认为您不需要这些值,但它们可能包括拇指指纹和发行者值用于验证令牌时所看到的效果。

我尝试在下面属于startup.cs文件的代码中复制所有原始配置设置。your x.509 cert string值可以从MetadataAddress url的xml文件中检索。它将位于<X509Certificate>标记之间。

代码语言:javascript
复制
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登录页面。但是,我无法登录,因为我没有权限;所以我不知道在您登录后帖子上会发生什么。如果你有问题,可以随时通知我。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55958701

复制
相关文章

相似问题

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