为了准备我的应用程序以使用 ADFS,我必须与联邦合作,现在我们有一个解决方案,该服务器具有使用 WIF 的联合服务以确保安全,有一个客户端使用此服务,我们有一个使用用户名密码的 STS 用于识别用户。
一切正常,我的所有声明都正确生成,我可以在我的应用程序中使用它们。
现在除了我们的 Internal IdentityProvider 之外,我们还必须使用 ADFS,我只需将我的 sts 分成两部分,一个由客户端调用并由服务器信任的“联合提供程序”,以及一个负责身份验证的部分为此我只是添加在 FederationProvider 中的 CustomSecurityTokenHandler 中的以下代码
UserNameSecurityToken userNameTokenFromRP = token as UserNameSecurityToken;
WSTrustChannelFactory stsClient = new WSTrustChannelFactory("IdentityConfiguration");
stsClient.Credentials.UserName.UserName = userNameTokenFromRP.UserName;
stsClient.Credentials.UserName.Password = userNameTokenFromRP.Password;
IWSTrustChannelContract stsProxy = stsClient.CreateChannel();
RequestSecurityToken rst = new RequestSecurityToken(WSTrust13Constants.RequestTypes.Issue, WSTrust13Constants.KeyTypes.Symmetric);
rst.AppliesTo = new System.ServiceModel.EndpointAddress("http://localhost:8010/FederationProvider.svc");
rst.Claims.Add(new RequestClaim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", false));
rst.Issuer = new System.ServiceModel.EndpointAddress("http://localhost:8020/IdentityProvider.svc");
rst.Lifetime = new Lifetime(DateTime.Now, DateTime.Now + new TimeSpan(0, 30, 0));
rst.TokenType = Microsoft.IdentityModel.Tokens.SecurityTokenTypes.OasisWssSaml11TokenProfile11;
RequestSecurityTokenResponse rstr;
var stsToken = stsProxy.Issue(rst, out rstr);
这在我的 Web.config 文件中:
<client>
<endpoint name="IdentityConfiguration" address="http://localhost:8020/IdentityProvider.svc"
binding="ws2007HttpBinding" bindingConfiguration="SecurityTokenBinding"
contract="Microsoft.IdentityModel.Protocols.WSTrust.IWSTrustChannelContract">
<identity>
<certificate encodedValue="MyEncodedValue" />
</identity>
</endpoint>
</client>
在身份方面,我继续以与之前相同的方式生成声明我遇到的问题是在我的 RSTR 中,令牌为空并且 tokenXML 已加密,我不明白在这种情况下如何使用联合?
如果有人可以帮助我?
谢谢你读我
安格