@@ -18,7 +18,7 @@ namespace Fido2Demo;
1818public class TestController : Controller
1919{
2020 /* CONFORMANCE TESTING ENDPOINTS */
21- private static readonly DevelopmentInMemoryStore DemoStorage = new ( ) ;
21+ private static readonly DevelopmentInMemoryStore _demoStorage = new ( ) ;
2222
2323 private readonly IFido2 _fido2 ;
2424 private readonly string _origin ;
@@ -56,15 +56,15 @@ public JsonResult MakeCredentialOptionsTest([FromBody] TEST_MakeCredentialParams
5656 }
5757
5858 // 1. Get user from DB by username (in our example, auto create missing users)
59- var user = DemoStorage . GetOrAddUser ( opts . Username , ( ) => new Fido2User
59+ var user = _demoStorage . GetOrAddUser ( opts . Username , ( ) => new Fido2User
6060 {
6161 DisplayName = opts . DisplayName ,
6262 Name = opts . Username ,
6363 Id = username // byte representation of userID is required
6464 } ) ;
6565
6666 // 2. Get user existing keys by username
67- var existingKeys = DemoStorage . GetCredentialsByUser ( user ) . Select ( c => c . Descriptor ) . ToList ( ) ;
67+ var existingKeys = _demoStorage . GetCredentialsByUser ( user ) . Select ( c => c . Descriptor ) . ToList ( ) ;
6868
6969 //var exts = new AuthenticationExtensionsClientInputs() { Extensions = true, UserVerificationIndex = true, Location = true, UserVerificationMethod = true, BiometricAuthenticatorPerformanceBounds = new AuthenticatorBiometricPerfBounds { FAR = float.MaxValue, FRR = float.MaxValue } };
7070 var exts = new AuthenticationExtensionsClientInputs ( ) { } ;
@@ -83,7 +83,7 @@ public JsonResult MakeCredentialOptionsTest([FromBody] TEST_MakeCredentialParams
8383
8484 [ HttpPost ]
8585 [ Route ( "/attestation/result" ) ]
86- public async Task < JsonResult > MakeCredentialResultTest ( [ FromBody ] AuthenticatorAttestationRawResponse attestationResponse , CancellationToken cancellationToken )
86+ public async Task < JsonResult > MakeCredentialResultTestAsync ( [ FromBody ] AuthenticatorAttestationRawResponse attestationResponse , CancellationToken cancellationToken )
8787 {
8888
8989 // 1. get the options we sent the client
@@ -93,20 +93,20 @@ public async Task<JsonResult> MakeCredentialResultTest([FromBody] AuthenticatorA
9393 // 2. Create callback so that lib can verify credential id is unique to this user
9494 IsCredentialIdUniqueToUserAsyncDelegate callback = static async ( args , cancellationToken ) =>
9595 {
96- var users = await DemoStorage . GetUsersByCredentialIdAsync ( args . CredentialId , cancellationToken ) ;
96+ var users = await _demoStorage . GetUsersByCredentialIdAsync ( args . CredentialId , cancellationToken ) ;
9797 return users . Count <= 0 ;
9898 } ;
9999
100100 // 2. Verify and make the credentials
101101 var success = await _fido2 . MakeNewCredentialAsync ( attestationResponse , options , callback , cancellationToken : cancellationToken ) ;
102102
103103 // 3. Store the credentials in db
104- DemoStorage . AddCredentialToUser ( options . User , new StoredCredential
104+ _demoStorage . AddCredentialToUser ( options . User , new StoredCredential
105105 {
106106 Descriptor = new PublicKeyCredentialDescriptor ( success . Result . CredentialId ) ,
107107 PublicKey = success . Result . PublicKey ,
108108 UserHandle = success . Result . User . Id ,
109- SignatureCounter = success . Result . Counter
109+ SignCount = success . Result . Counter
110110 } ) ;
111111
112112 // 4. return "ok" to the client
@@ -119,12 +119,12 @@ public IActionResult AssertionOptionsTest([FromBody] TEST_AssertionClientParams
119119 {
120120 var username = assertionClientParams . Username ;
121121 // 1. Get user from DB
122- var user = DemoStorage . GetUser ( username ) ;
122+ var user = _demoStorage . GetUser ( username ) ;
123123 if ( user == null )
124124 return NotFound ( "username was not registered" ) ;
125125
126126 // 2. Get registered credentials from database
127- var existingCredentials = DemoStorage . GetCredentialsByUser ( user ) . Select ( c => c . Descriptor ) . ToList ( ) ;
127+ var existingCredentials = _demoStorage . GetCredentialsByUser ( user ) . Select ( c => c . Descriptor ) . ToList ( ) ;
128128
129129 var uv = assertionClientParams . UserVerification ;
130130 if ( null != assertionClientParams . authenticatorSelection )
@@ -154,30 +154,33 @@ public IActionResult AssertionOptionsTest([FromBody] TEST_AssertionClientParams
154154
155155 [ HttpPost ]
156156 [ Route ( "/assertion/result" ) ]
157- public async Task < JsonResult > MakeAssertionTest ( [ FromBody ] AuthenticatorAssertionRawResponse clientResponse , CancellationToken cancellationToken )
157+ public async Task < JsonResult > MakeAssertionTestAsync ( [ FromBody ] AuthenticatorAssertionRawResponse clientResponse , CancellationToken cancellationToken )
158158 {
159159 // 1. Get the assertion options we sent the client
160160 var jsonOptions = HttpContext . Session . GetString ( "fido2.assertionOptions" ) ;
161161 var options = AssertionOptions . FromJson ( jsonOptions ) ;
162162
163163 // 2. Get registered credential from database
164- var creds = DemoStorage . GetCredentialById ( clientResponse . Id ) ;
164+ var creds = _demoStorage . GetCredentialById ( clientResponse . Id ) ;
165165
166166 // 3. Get credential counter from database
167167 var storedCounter = creds . SignatureCounter ;
168168
169169 // 4. Create callback to check if userhandle owns the credentialId
170170 IsUserHandleOwnerOfCredentialIdAsync callback = static async ( args , cancellationToken ) =>
171171 {
172- var storedCreds = await DemoStorage . GetCredentialsByUserHandleAsync ( args . UserHandle , cancellationToken ) ;
172+ var storedCreds = await _demoStorage . GetCredentialsByUserHandleAsync ( args . UserHandle , cancellationToken ) ;
173173 return storedCreds . Exists ( c => c . Descriptor . Id . SequenceEqual ( args . CredentialId ) ) ;
174174 } ;
175175
176176 // 5. Make the assertion
177- var res = await _fido2 . MakeAssertionAsync ( clientResponse , options , creds . PublicKey , storedCounter , callback , cancellationToken : cancellationToken ) ;
177+ var res = await _fido2 . MakeAssertionAsync ( clientResponse , options , creds . PublicKey , creds . DevicePublicKeys , storedCounter , callback , cancellationToken : cancellationToken ) ;
178178
179179 // 6. Store the updated counter
180- DemoStorage . UpdateCounter ( res . CredentialId , res . Counter ) ;
180+ _demoStorage . UpdateCounter ( res . CredentialId , res . Counter ) ;
181+
182+ if ( res . DevicePublicKey is not null )
183+ creds . DevicePublicKeys . Add ( res . DevicePublicKey ) ;
181184
182185 var testRes = new
183186 {
0 commit comments