Skip to content

Commit

Permalink
Make Origins readonly
Browse files Browse the repository at this point in the history
Closes #392
  • Loading branch information
Regenhardt committed May 17, 2023
1 parent a33848c commit cf00991
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Demo/TestController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

namespace Fido2Demo;

using System.Collections.Generic;

public class TestController : Controller
{
/* CONFORMANCE TESTING ENDPOINTS */
Expand All @@ -31,7 +33,7 @@ public TestController(IOptions<Fido2Configuration> fido2Configuration)
{
ServerDomain = fido2Configuration.Value.ServerDomain,
ServerName = fido2Configuration.Value.ServerName,
Origins = fido2Configuration.Value.FullyQualifiedOrigins,
Origins = (IReadOnlySet<string>)fido2Configuration.Value.FullyQualifiedOrigins,
},
ConformanceTesting.MetadataServiceInstance(
System.IO.Path.Combine(fido2Configuration.Value.MDSCacheDirPath, @"Conformance"), _origin)
Expand Down
15 changes: 6 additions & 9 deletions Src/Fido2.Models/Fido2Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Fido2NetLib;

public class Fido2Configuration
{
private ISet<string> _origins;
private IReadOnlySet<string> _origins;
private ISet<string> _fullyQualifiedOrigins;

/// <summary>
Expand Down Expand Up @@ -56,20 +56,17 @@ public Fido2Configuration()
/// <summary>
/// Server origins, including protocol host and port.
/// </summary>
public ISet<string> Origins
public IReadOnlySet<string> Origins
{
get
{
if (_origins == null)
{
_origins = new HashSet<string>();

// Since we're depricating Origin we ease the transition to move the value automatically, unless its null
// Since we're deprecating Origin we ease the transition to move the value automatically, unless its null
#pragma warning disable CS0618 // Type or member is obsolete
if (Origin != null)
{
_origins.Add(Origin);
}
_origins = Origins != null
? new HashSet<string>(new[] { Origin })
: new HashSet<string>();
#pragma warning restore CS0618 // Type or member is obsolete
}

Expand Down

0 comments on commit cf00991

Please sign in to comment.