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 KeyManagementOptions binding #1375

Merged
merged 1 commit into from
Jul 19, 2023
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using static Duende.IdentityServer.IdentityServerConstants;
Expand All @@ -31,7 +32,7 @@ public class KeyManagementOptions
/// If none are specified, then "RS256" will be used as the default.
/// The first in the collection will be used as the default.
/// </summary>
public IEnumerable<SigningAlgorithmOptions> SigningAlgorithms { get; set; } = Enumerable.Empty<SigningAlgorithmOptions>();
public ICollection<SigningAlgorithmOptions> SigningAlgorithms { get; set; } = new List<SigningAlgorithmOptions>();

internal string DefaultSigningAlgorithm => SigningAlgorithms.First().Name;
internal IEnumerable<string> AllowedSigningAlgorithmNames => SigningAlgorithms.Select(x => x.Name);
Expand Down Expand Up @@ -160,9 +161,18 @@ internal void Validate()
/// </summary>
public class SigningAlgorithmOptions
{
/// <summary>
/// Parameterless constructor, required for binding
/// </summary>
public SigningAlgorithmOptions()
{

}

/// <summary>
/// Constructor.
/// </summary>
[SetsRequiredMembers]
public SigningAlgorithmOptions(string name)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
Expand All @@ -171,7 +181,7 @@ public SigningAlgorithmOptions(string name)
/// <summary>
/// The algorithm name.
/// </summary>
public string Name { get; set; }
public required string Name { get; set; }

/// <summary>
/// Indicates if an X.509 certificate is to be used to contain the key. Defaults to false.
Expand Down