Skip to content

Commit

Permalink
Merge pull request #17 from DuendeSoftware/brock/rename
Browse files Browse the repository at this point in the history
rename algorithms on key mgmt options
  • Loading branch information
brockallen authored Nov 24, 2020
2 parents a6547ea + 56b2acf commit f29514a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ 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> AllowedSigningAlgorithms { get; set; } = Enumerable.Empty<SigningAlgorithmOptions>();
public IEnumerable<SigningAlgorithmOptions> SigningAlgorithms { get; set; } = Enumerable.Empty<SigningAlgorithmOptions>();

internal string DefaultSigningAlgorithm => AllowedSigningAlgorithms.First().Name;
internal IEnumerable<string> AllowedSigningAlgorithmNames => AllowedSigningAlgorithms.Select(x => x.Name);
internal string DefaultSigningAlgorithm => SigningAlgorithms.First().Name;
internal IEnumerable<string> AllowedSigningAlgorithmNames => SigningAlgorithms.Select(x => x.Name);

/// <summary>
/// When no keys have been created yet, this is the window of time considered to be an initialization
Expand Down Expand Up @@ -100,13 +100,13 @@ public class KeyManagementOptions

internal void Validate()
{
if (AllowedSigningAlgorithms?.Any() != true)
if (SigningAlgorithms?.Any() != true)
{
AllowedSigningAlgorithms = new[] { new SigningAlgorithmOptions("RS256") };
SigningAlgorithms = new[] { new SigningAlgorithmOptions("RS256") };
}
else
{
var group = AllowedSigningAlgorithms.GroupBy(x => x.Name);
var group = SigningAlgorithms.GroupBy(x => x.Name);
var dups = group.Where(x => x.Count() > 1);
if (dups.Any())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ internal async Task<IEnumerable<KeyContainer>> GetKeysFromStoreAsync(bool cache
var keys = new List<KeyContainer>();
keys.AddRange(await _cache.GetKeysAsync() ?? Enumerable.Empty<KeyContainer>());

foreach (var alg in _options.AllowedSigningAlgorithms)
foreach (var alg in _options.SigningAlgorithms)
{
var newKey = await CreateAndStoreNewKeyAsync(alg);
keys.Add(newKey);
Expand Down Expand Up @@ -622,7 +622,7 @@ internal bool CanBeUsedAsCurrentSigningKey(KeyContainer key, bool ignoreActiveDe
{
if (key == null) return false;

var alg = _options.AllowedSigningAlgorithms.SingleOrDefault(x => x.Name == key.Algorithm);
var alg = _options.SigningAlgorithms.SingleOrDefault(x => x.Name == key.Algorithm);
if (alg == null)
{
_logger.LogTrace("Key {kid} signing algorithm {alg} not allowed by server options.", key.Id, key.Algorithm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class KeyManagerTests

public KeyManagerTests()
{
_options.AllowedSigningAlgorithms = new[] { _rsaOptions };
_options.SigningAlgorithms = new[] { _rsaOptions };

_subject = new KeyManager(
_options,
Expand Down

0 comments on commit f29514a

Please sign in to comment.