Skip to content

Commit 53caf81

Browse files
authored
Remove Origin property and make Origins readonly (#393)
1 parent 2cc296d commit 53caf81

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

Demo/TestController.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
using Microsoft.AspNetCore.Http;
1212
using Microsoft.AspNetCore.Mvc;
13-
using Microsoft.Extensions.Caching.Distributed;
1413
using Microsoft.Extensions.Options;
1514

1615
namespace Fido2Demo;

Src/Fido2.Models/Fido2Configuration.cs

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ namespace Fido2NetLib;
77

88
public class Fido2Configuration
99
{
10-
private ISet<string> _origins;
11-
private ISet<string> _fullyQualifiedOrigins;
10+
private IReadOnlySet<string> _origins;
11+
private IReadOnlySet<string> _fullyQualifiedOrigins;
1212

1313
/// <summary>
1414
/// Create the configuration for Fido2.
@@ -34,7 +34,7 @@ public Fido2Configuration()
3434
public int ChallengeSize { get; set; } = 16;
3535

3636
/// <summary>
37-
/// The effetive domain of the RP. Should be unique and will be used as the identity for the RP.
37+
/// The effective domain of the RP. Should be unique and will be used as the identity for the RP.
3838
/// </summary>
3939
public string ServerDomain { get; set; }
4040

@@ -48,30 +48,16 @@ public Fido2Configuration()
4848
/// </summary>
4949
public string ServerIcon { get; set; }
5050

51-
/// <summary>
52-
/// Server origin, including protocol host and port.
53-
/// </summary>
54-
[Obsolete("This property is obsolete. Use Origins instead.")]
55-
public string Origin { get; set; }
56-
5751
/// <summary>
5852
/// Server origins, including protocol host and port.
5953
/// </summary>
60-
public ISet<string> Origins
54+
public IReadOnlySet<string> Origins
6155
{
6256
get
6357
{
6458
if (_origins == null)
6559
{
66-
_origins = new HashSet<string>();
67-
68-
// Since we're depricating Origin we ease the transition to move the value automatically, unless its null
69-
#pragma warning disable CS0618 // Type or member is obsolete
70-
if (Origin != null)
71-
{
72-
_origins.Add(Origin);
73-
}
74-
#pragma warning restore CS0618 // Type or member is obsolete
60+
_origins = new HashSet<string>(0);
7561
}
7662

7763
return _origins;
@@ -87,15 +73,17 @@ public ISet<string> Origins
8773
/// <summary>
8874
/// Fully Qualified Server origins, generated automatically from Origins.
8975
/// </summary>
90-
public ISet<string> FullyQualifiedOrigins
76+
public IReadOnlySet<string> FullyQualifiedOrigins
9177
{
92-
get => _fullyQualifiedOrigins ?? new HashSet<string>
78+
get
9379
{
94-
#pragma warning disable CS0618
95-
Origin?.ToFullyQualifiedOrigin()
96-
#pragma warning restore CS0618
97-
};
98-
private set => _fullyQualifiedOrigins = value;
80+
if (_fullyQualifiedOrigins == null)
81+
{
82+
Origins = new HashSet<string>(0);
83+
}
84+
85+
return _fullyQualifiedOrigins;
86+
}
9987
}
10088

10189
/// <summary>

Src/Fido2/AuthenticatorResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ protected AuthenticatorResponse(ReadOnlySpan<byte> utf8EncodedJson)
6363
[JsonPropertyName("origin")]
6464
public string Origin { get; set; }
6565

66-
protected void BaseVerify(ISet<string> fullyQualifiedExpectedOrigins, ReadOnlySpan<byte> originalChallenge)
66+
protected void BaseVerify(IReadOnlySet<string> fullyQualifiedExpectedOrigins, ReadOnlySpan<byte> originalChallenge)
6767
{
6868
if (Type is not "webauthn.create" && Type is not "webauthn.get")
6969
throw new Fido2VerificationException(Fido2ErrorCode.InvalidAuthenticatorResponse, $"Type must be 'webauthn.create' or 'webauthn.get'. Was '{Type}'");

0 commit comments

Comments
 (0)