Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RST generation issues in WsFederation #4322

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</PropertyGroup>

<PropertyGroup>
<MicrosoftIdentityModelProtocolsWsTrustPackageVersion>6.6.1-preview-10617201806</MicrosoftIdentityModelProtocolsWsTrustPackageVersion>
<MicrosoftIdentityModelProtocolsWsTrustPackageVersion>6.7.2-preview-10803222715</MicrosoftIdentityModelProtocolsWsTrustPackageVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,19 @@ protected virtual WsTrustRequest CreateWsTrustRequest()
Context = RequestContext,
KeySizeInBits = keySize,
KeyType = keyType,
TokenType = SecurityTokenRequirement.TokenType,
WsTrustVersion = _requestSerializationContext.TrustVersion
};

if (SecurityTokenRequirement.TokenType != null)
{
trustRequest.TokenType = SecurityTokenRequirement.TokenType;
}

if (entropy != null)
{
trustRequest.Entropy = entropy;
trustRequest.ComputedKeyAlgorithm = _requestSerializationContext.TrustKeyTypes.PSHA1;
}

return trustRequest;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
#pragma warning disable 1591

using System.IdentityModel.Selectors;
using System.ServiceModel.Security.Tokens;
using Microsoft.IdentityModel.Logging;
using Microsoft.IdentityModel.Tokens.Saml;
using Microsoft.IdentityModel.Tokens.Saml2;

namespace System.ServiceModel.Federation
{
Expand All @@ -16,6 +15,9 @@ namespace System.ServiceModel.Federation
/// </summary>
public class WsTrustChannelSecurityTokenManager : ClientCredentialsSecurityTokenManager
{
private const string Namespace = "http://schemas.microsoft.com/ws/2006/05/servicemodel/securitytokenrequirement";
private const string IssuedSecurityTokenParametersProperty = Namespace + "/IssuedSecurityTokenParameters";

private WsTrustChannelClientCredentials _wsTrustChannelClientCredentials;

/// <summary>
Expand All @@ -38,10 +40,10 @@ public override SecurityTokenProvider CreateSecurityTokenProvider(SecurityTokenR
if (tokenRequirement == null)
throw LogHelper.LogArgumentNullException(nameof(tokenRequirement));

// TODO - we should check the value of the IssuedTokenType on WsTrustTokenParameters
if (Saml2Constants.OasisWssSaml2TokenProfile11.Equals(tokenRequirement.TokenType) ||
Saml2Constants.Saml2TokenProfile11.Equals(tokenRequirement.TokenType) ||
SamlConstants.OasisWssSamlTokenProfile11.Equals(tokenRequirement.TokenType))
// If the token requirement includes an issued security token parameter of type
// WsTrustTokenParameters, then tokens should be provided by a WsTrustChannelSecurityTokenProvider.
if (tokenRequirement.TryGetProperty(IssuedSecurityTokenParametersProperty, out SecurityTokenParameters issuedSecurityTokenParameters) &&
mjrousos marked this conversation as resolved.
Show resolved Hide resolved
issuedSecurityTokenParameters is WsTrustTokenParameters)
{
// pass issuedtokenRequirements
return new WsTrustChannelSecurityTokenProvider(tokenRequirement)
Expand Down