c#-将mvc 5 adfs转换为.net core adfs
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c#-将mvc 5 adfs转换为.net core adfs,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2843字,纯文字阅读大概需要5分钟。
内容图文
![c#-将mvc 5 adfs转换为.net core adfs](/upload/InfoBanner/zyjiaocheng/670/4bb4fa340b23451e96616d8a55f82188.jpg)
我有一个现有的mvc 5应用程序,可以成功使用内部活动目录联合服务
相关的网络配置设置
<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中的内容
所以我有
.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领域中添加什么,因为我没有使用Azure.我也不需要指纹和发行人吗? http://www.fedsvc3copa.beta.pa.gov/adfs/services/trust
解决方法:
要回答您的第一个问题:
如果您不使用Azure,则无需担心AAD.实际上,您要确保未对.Wtrealm进行两次配置.因此,只需删除第二个.
要回答有关指纹和发行者的第二个问题:
我认为您不需要这些值,但是将它们包括在内似乎很有用,因为指纹和发行者值用于验证令牌.
我尝试在下面的代码中复制您的所有原始配置设置,这些代码属于startup.cs文件.您的x.509证书字符串值可以从MetadataAddress URL的xml文件中检索.它将在< X509Certificate>与标签.
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登录页面.但是,由于我没有权限,因此无法登录.因此,我不知道登录后会在POST上发生什么.如果遇到问题,请随时告诉我.
内容总结
以上是互联网集市为您收集整理的c#-将mvc 5 adfs转换为.net core adfs全部内容,希望文章能够帮你解决c#-将mvc 5 adfs转换为.net core adfs所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。