1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef DEVICE_FIDO_AUTHENTICATOR_SELECTION_CRITERIA_H_ 6 #define DEVICE_FIDO_AUTHENTICATOR_SELECTION_CRITERIA_H_ 7 8 #include "base/component_export.h" 9 #include "device/fido/fido_constants.h" 10 11 namespace device { 12 13 // Represents authenticator properties the relying party can specify to restrict 14 // the type of authenticator used in creating credentials. 15 // https://w3c.github.io/webauthn/#authenticatorSelection COMPONENT_EXPORT(DEVICE_FIDO)16class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorSelectionCriteria { 17 public: 18 AuthenticatorSelectionCriteria(); 19 AuthenticatorSelectionCriteria( 20 AuthenticatorAttachment authenticator_attachment, 21 bool require_resident_key, 22 UserVerificationRequirement user_verification_requirement); 23 AuthenticatorSelectionCriteria(const AuthenticatorSelectionCriteria& other); 24 AuthenticatorSelectionCriteria(AuthenticatorSelectionCriteria&& other); 25 AuthenticatorSelectionCriteria& operator=( 26 const AuthenticatorSelectionCriteria& other); 27 AuthenticatorSelectionCriteria& operator=( 28 AuthenticatorSelectionCriteria&& other); 29 bool operator==(const AuthenticatorSelectionCriteria& other) const; 30 ~AuthenticatorSelectionCriteria(); 31 32 AuthenticatorAttachment authenticator_attachment() const { 33 return authenticator_attachment_; 34 } 35 36 bool require_resident_key() const { return require_resident_key_; } 37 38 UserVerificationRequirement user_verification_requirement() const { 39 return user_verification_requirement_; 40 } 41 42 void SetAuthenticatorAttachmentForTesting( 43 AuthenticatorAttachment attachment) { 44 authenticator_attachment_ = attachment; 45 } 46 void SetRequireResidentKeyForTesting(bool require) { 47 require_resident_key_ = require; 48 } 49 void SetUserVerificationRequirementForTesting( 50 UserVerificationRequirement uv) { 51 user_verification_requirement_ = uv; 52 } 53 54 private: 55 AuthenticatorAttachment authenticator_attachment_ = 56 AuthenticatorAttachment::kAny; 57 bool require_resident_key_ = false; 58 UserVerificationRequirement user_verification_requirement_ = 59 UserVerificationRequirement::kPreferred; 60 }; 61 62 } // namespace device 63 64 #endif // DEVICE_FIDO_AUTHENTICATOR_SELECTION_CRITERIA_H_ 65