Skip to content
This repository was archived by the owner on Jul 25, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
614558e
Hotfix
Blobonat Jul 1, 2020
d08fd5f
Clean up
Blobonat Jul 1, 2020
b1a94ba
Add recovery key loading
Blobonat Jul 2, 2020
bed610f
Export/Import crypto key for storage
Blobonat Jul 3, 2020
b6cbcec
Use credential id of backup key
Blobonat Jul 3, 2020
5d5dacf
Add psk registration flow
Blobonat Jul 3, 2020
87298a0
Typo
Blobonat Jul 5, 2020
87bc617
Adapt method names
Blobonat Jul 6, 2020
5349bd7
Recovery key download
Blobonat Jul 6, 2020
c3a1172
Improve logging/method names
Blobonat Jul 9, 2020
24e6be5
Setup recovery flow
Blobonat Jul 9, 2020
9acdf6c
Encoding recovery message
Blobonat Jul 10, 2020
79fe285
Encoding adaption
Blobonat Jul 11, 2020
a289b77
Encoding
Blobonat Jul 12, 2020
cead4ac
Add attestation object during recovery
Blobonat Jul 13, 2020
b96978d
Add upload for delegation and backup
Blobonat Jul 15, 2020
6dd6ede
Bugfix/webauthn conformity (#1)
Blobonat Jul 16, 2020
ad08bba
Finish basic recovery flow
Blobonat Jul 16, 2020
5f018cd
Refactoring
Blobonat Jul 19, 2020
d06fb4c
Clean up
Blobonat Jul 20, 2020
02dade4
Add new backup key during recovery
Blobonat Jul 24, 2020
033d337
Use CBOR canonical encoding
Blobonat Jul 25, 2020
5903cea
Fix encoding for key inside authenticator data
Blobonat Jul 25, 2020
51a9bc0
Use REST endpoint for backup device communication
Blobonat Jul 26, 2020
82a80fd
Store attestation object inside backup key
Blobonat Jul 28, 2020
77da7c2
Fix encoding problems of BD attestation object
Blobonat Jul 29, 2020
c7d2bdb
Clean up
Blobonat Jul 29, 2020
0f4bea9
Adapt recovery flow
Blobonat Jul 30, 2020
2e206aa
Fix storage problems
Blobonat Jul 31, 2020
2a2827b
Add padding during recovery request
Blobonat Jul 31, 2020
f6e25ae
Handle all credentials inside PublicKeyRequestOptions
Blobonat Aug 1, 2020
f9785b5
Code style
Blobonat Aug 1, 2020
22056e0
Add constant AAGUID
Blobonat Aug 3, 2020
ead3a05
Add separate config page
Blobonat Aug 3, 2020
db67616
Add recovery and setup function to config page
Blobonat Aug 6, 2020
26c9e2b
Use PublicKeyCredentialSource
Blobonat Aug 18, 2020
6e1d2f7
Check excludeCredentials before generating new credential
Blobonat Aug 22, 2020
0a09dcd
Change PSK setup message structure
Blobonat Aug 22, 2020
98a8338
Started separation of client and authenticator
Blobonat Aug 22, 2020
930a75c
Finished registration flow
Blobonat Aug 23, 2020
3cfe685
Add attestation
Blobonat Aug 23, 2020
b822259
Add assertion flow
Blobonat Aug 24, 2020
29ff52d
Clean up
Blobonat Aug 24, 2020
9523e78
Make credential source lookup during assertion more web authn conform
Blobonat Aug 24, 2020
419a2fb
Added basic structure for PSK registration
Blobonat Aug 25, 2020
6aa4a47
Fix PSK encoding
Blobonat Aug 26, 2020
35d0d7d
Create client extension output during credential creation
Blobonat Aug 26, 2020
e2021fc
Add recovery setup
Blobonat Aug 27, 2020
27d8008
Add recovery flow on authenticator
Blobonat Aug 27, 2020
c15b1e3
Adapt recovery flow
Blobonat Aug 28, 2020
57f1760
Fix recovery input validation
Blobonat Aug 28, 2020
5383e34
Clean up
Blobonat Aug 30, 2020
236867b
Fix BD endpoint URL option persistence
Blobonat Aug 31, 2020
147081a
Clean up make credential
Blobonat Sep 5, 2020
102fc81
Clean up get credential
Blobonat Sep 5, 2020
a9b0686
Add auth alias to options
Blobonat Sep 6, 2020
f45f56c
Encode attestation object during recovery in base64 URL
Blobonat Sep 6, 2020
f393678
Moved user interaction from authenticator to BD
Blobonat Sep 11, 2020
0941731
Adapt Sync messages
Blobonat Sep 14, 2020
f6f0889
Remove redundant CBOR encapsulation
Blobonat Sep 17, 2020
4fec8cc
Add BD authData to recovery key
Blobonat Sep 30, 2020
bde8973
Add BD recovery
Blobonat Oct 1, 2020
6e6a4ff
Remove unnecessary CBOR encoding in PSK Authentication Extension
Blobonat Oct 5, 2020
c71d62d
Abort registration if one BD has no backup keys
Blobonat Oct 7, 2020
91b93fb
Add user verification
Blobonat Oct 7, 2020
acc2c7d
Add user verification and encryption
Blobonat Oct 9, 2020
6093413
Remove base64 in PSK extension
Blobonat Oct 10, 2020
fb368d5
Fix icon display bug
Blobonat Oct 12, 2020
427d32a
Update names
Blobonat Oct 21, 2020
d5ac8c3
Add user handle to PSK extension
Blobonat Oct 23, 2020
977deec
Add client extension output
Blobonat Oct 23, 2020
c4f0194
Fox encrypted storage operations before UV is finished
Blobonat Oct 26, 2020
0b618e2
1 PSK setup API endpoint
Blobonat Oct 27, 2020
7c22b0e
Fix backup key storage
Blobonat Oct 28, 2020
e70ea55
Fast lookup for recovery keys
Blobonat Oct 28, 2020
af17071
Recovery Setup Response key match simplified
Blobonat Oct 28, 2020
e04348e
Fix authenticatorAttachment bug
Blobonat Oct 28, 2020
0a4c5c5
PSK error log
Blobonat Oct 29, 2020
3ff2bdb
Merge remote-tracking branch 'origin/pks'
Blobonat Nov 3, 2020
5c69c6e
Fix logging
Blobonat Nov 13, 2020
12aa653
Add OS Support section
Blobonat Nov 17, 2020
d9ee899
Use PSK extension identifier with capital letters
Blobonat Jan 10, 2021
0a2cc50
Merge remote-tracking branch 'origin/master'
Blobonat Jan 10, 2021
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
Prev Previous commit
Next Next commit
Clean up get credential
  • Loading branch information
Blobonat committed Sep 5, 2020
commit 102fc8197292e8787dc5df940f76be516bdd67fe
6 changes: 3 additions & 3 deletions src/webauthn_authenticator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class Authenticator {
let isRecovery: [boolean, string] = [false, ""];
let credentialOptions: PublicKeyCredentialSource[] = [];
if (allowCredentialDescriptorList) {
// Simplified credential lookup
for (let i = 0; i < allowCredentialDescriptorList.length; i++) {
const rawCredId = allowCredentialDescriptorList[i].id as ArrayBuffer;
const credId = byteArrayToBase64(new Uint8Array(rawCredId), true);
Expand All @@ -59,6 +60,7 @@ export class Authenticator {
}
}
} else {
// If no credentials were supplied, load all credentials associated to the RPID
credentialOptions = credentialOptions.concat(await CredentialsMap.load(rpId));
}
if (credentialOptions.length == 0) {
Expand All @@ -75,6 +77,7 @@ export class Authenticator {
}
}
if (!isRecovery[0]) {
// No recovery and no associated credential found
throw new Error(`Container does not manage any related credentials`);
}
}
Expand All @@ -84,7 +87,6 @@ export class Authenticator {
credSource = credentialOptions[0];
}


const userConsent = await userConsentCallback;
if (!userConsent) {
throw new Error(`no user consent`);
Expand All @@ -93,15 +95,13 @@ export class Authenticator {
// Step 8
let processedExtensions = undefined;
if (extensions) {
log.debug(extensions);
if (extensions.has(PSK_EXTENSION_IDENTIFIER)) {
log.debug('Get: PSK requested');
if (!isRecovery[0]) {
throw new Error('PSK extension requested, but no matching recovery key available');
}
const rawPskInput = base64ToByteArray(extensions.get(PSK_EXTENSION_IDENTIFIER), true);
const pskInput = await CBOR.decode(new Buffer(rawPskInput));
log.debug('Get: PSK input', pskInput);
const [newCredId, pskOutput] = await PSK.authenticatorGetCredentialExtensionOutput(isRecovery[1], pskInput.hash, rpId);
processedExtensions = new Map([[PSK_EXTENSION_IDENTIFIER, pskOutput]]);
credSource = await CredentialsMap.lookup(rpId, newCredId);
Expand Down
23 changes: 20 additions & 3 deletions src/webauthn_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,18 @@ export async function createPublicKeyCredential(origin: string, options: Credent
}

export async function getPublicKeyCredential(origin: string, options: CredentialRequestOptions, sameOriginWithAncestors: boolean, userConsentCallback: Promise<boolean>) {
// Step 1
if (!options.publicKey) {
throw new Error('options missing');
}

// Step 2
if (!sameOriginWithAncestors) {
throw new Error(`sameOriginWithAncestors has to be true`);
}

// No timeout

// Step 7
const rpID = options.publicKey.rpId || getDomainFromOrigin(origin);

Expand All @@ -136,6 +143,8 @@ export async function getPublicKeyCredential(origin: string, options: Credential
const authenticatorExtensionInput = new Uint8Array(CBOR.encodeCanonical({hash: customClientDataHash}));
authenticatorExtensions = new Map([[PSK_EXTENSION_IDENTIFIER, byteArrayToBase64(authenticatorExtensionInput, true)]]);
// clientExtensions = {[PSK_EXTENSION_IDENTIFIER]: {clientDataJSON: customClientDataJSON}}; // ToDo Add to response
} else {
log.warn('PSK client extension processing failed. Wrong input.');
}
}
}
Expand All @@ -147,21 +156,29 @@ export async function getPublicKeyCredential(origin: string, options: Credential
const clientDataHashDigest = await window.crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(clientDataJSON)));
const clientDataHash = new Uint8Array(clientDataHashDigest);

// Step 18: Simplified, just for 1 authenticator
// Handle only 1 authenticator
// Step 18
if (options.publicKey.userVerification && (options.publicKey.userVerification === 'required')) {
throw new Error(`cKey does not support user verification`);
}

const userVerification = options.publicKey.userVerification === "required";
const userPresence = !userVerification;

const allowCredentialDescriptorList = options.publicKey.allowCredentials; // No filtering

const assertionCreationData = await Authenticator.authenticatorGetAssertion(userConsentCallback,
rpID,
clientDataHash,
userPresence,
userVerification,
options.publicKey.allowCredentials,
allowCredentialDescriptorList,
authenticatorExtensions);

log.debug('Received assertion response');

return {
getClientExtensionResults: () => ({}),
getClientExtensionResults: () => (clientExtensions), // ToDo Add client extension output
id: assertionCreationData.credentialId,
rawId: base64ToByteArray(assertionCreationData.credentialId, true),
response: {
Expand Down