Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
24 changes: 20 additions & 4 deletions src/AspNet.Security.OpenId/OpenIdAuthenticationHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,17 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop

foreach (var attribute in Options.Attributes)
{
message.SetParameter(
prefix: OpenIdAuthenticationConstants.Prefixes.Ax,
name: $"{OpenIdAuthenticationConstants.Prefixes.Type}.{attribute.Key}",
value: attribute.Value);
if (attribute.Key.StartsWith("openid.ns"))
{
message.Parameters.Add(attribute.Key, attribute.Value);
}
else
{
message.SetParameter(
prefix: OpenIdAuthenticationConstants.Prefixes.Ax,
name: $"{OpenIdAuthenticationConstants.Prefixes.Type}.{attribute.Key}",
value: attribute.Value);
}
}

// openid.ax.required
Expand All @@ -323,6 +330,15 @@ protected override async Task HandleChallengeAsync(AuthenticationProperties prop
value: string.Join(",", Options.Attributes.Select(attribute => attribute.Key)));
}

foreach (var prop in properties.Parameters)
{
if (prop.Value is string && message.GetParameter(prop.Key) == null)
{
message.SetParameter(prop.Key,
prop.Value.ToString());
}
}

var address = QueryHelpers.AddQueryString(configuration.AuthenticationEndpoint,
message.GetParameters()
.ToDictionary(parameter => parameter.Key,
Expand Down
2 changes: 1 addition & 1 deletion src/AspNet.Security.OpenId/OpenIdAuthenticationMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public string ReturnTo
/// <summary>
/// Gets the parameters associated with this OpenID message.
/// </summary>
protected IDictionary<string, string> Parameters { get; } =
public IDictionary<string, string> Parameters { get; } =
new Dictionary<string, string>(StringComparer.Ordinal);

/// <summary>
Expand Down