Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Added support for Exclusion List for WebAuthN.
Browse files Browse the repository at this point in the history
Fixes #1285
  • Loading branch information
Brandon-T committed Jul 30, 2019
1 parent 5eb1d7a commit 1706fa0
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Client/U2FExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,29 @@ class U2FExtensions: NSObject {
]
makeCredentialRequest.options = makeOptions

let exclusionList: [Any] = publicKey.excludeCredentials.compactMap({
let credentialDescriptor = YKFFIDO2PublicKeyCredentialDescriptor()
guard let credentialIdData = Data(base64Encoded: $0.id) else {
return nil
}

credentialDescriptor.credentialId = credentialIdData
credentialDescriptor.credentialType = {
let credType = YKFFIDO2PublicKeyCredentialType()
credType.name = "public-key"
return credType
}()

return credentialDescriptor
})

guard exclusionList.count == publicKey.excludeCredentials.count else {
sendFIDO2AuthenticationError(handle: handle)
return
}

makeCredentialRequest.excludeList = exclusionList

guard let fido2Service = YubiKitManager.shared.keySession.fido2Service else {
self.sendFIDO2RegistrationError(handle: handle)
return
Expand Down
7 changes: 7 additions & 0 deletions Client/WebAuthN/WebAuthnRegisterRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.


struct PublicKeyCredentialDescriptor: Decodable {
let type: String
let id: String
}

struct WebAuthnRegisterRequest: Decodable {
struct PublicKey: Decodable {
struct PubKeyCredParams: Decodable {
Expand Down Expand Up @@ -31,6 +37,7 @@ struct WebAuthnRegisterRequest: Decodable {
let user: User
let rp: Rp
let challenge: String
let excludeCredentials: [PublicKeyCredentialDescriptor]
}
let publicKey: PublicKey
}

0 comments on commit 1706fa0

Please sign in to comment.