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 #include "device/fido/fido_types.h" 11 12 namespace device { 13 14 // Represents authenticator properties the relying party can specify to restrict 15 // the type of authenticator used in creating credentials. 16 // 17 // https://w3c.github.io/webauthn/#authenticatorSelection COMPONENT_EXPORT(DEVICE_FIDO)18class COMPONENT_EXPORT(DEVICE_FIDO) AuthenticatorSelectionCriteria { 19 public: 20 AuthenticatorSelectionCriteria(); 21 AuthenticatorSelectionCriteria( 22 AuthenticatorAttachment authenticator_attachment, 23 ResidentKeyRequirement resident_key, 24 UserVerificationRequirement user_verification_requirement); 25 AuthenticatorSelectionCriteria(const AuthenticatorSelectionCriteria& other); 26 AuthenticatorSelectionCriteria(AuthenticatorSelectionCriteria&& other); 27 AuthenticatorSelectionCriteria& operator=( 28 const AuthenticatorSelectionCriteria& other); 29 AuthenticatorSelectionCriteria& operator=( 30 AuthenticatorSelectionCriteria&& other); 31 bool operator==(const AuthenticatorSelectionCriteria& other) const; 32 ~AuthenticatorSelectionCriteria(); 33 34 AuthenticatorAttachment authenticator_attachment() const { 35 return authenticator_attachment_; 36 } 37 38 ResidentKeyRequirement resident_key() const { return resident_key_; } 39 40 UserVerificationRequirement user_verification_requirement() const { 41 return user_verification_requirement_; 42 } 43 44 void SetAuthenticatorAttachmentForTesting( 45 AuthenticatorAttachment attachment) { 46 authenticator_attachment_ = attachment; 47 } 48 void SetResidentKeyForTesting(ResidentKeyRequirement resident_key) { 49 resident_key_ = resident_key; 50 } 51 void SetUserVerificationRequirementForTesting( 52 UserVerificationRequirement uv) { 53 user_verification_requirement_ = uv; 54 } 55 56 private: 57 AuthenticatorAttachment authenticator_attachment_ = 58 AuthenticatorAttachment::kAny; 59 ResidentKeyRequirement resident_key_ = ResidentKeyRequirement::kDiscouraged; 60 UserVerificationRequirement user_verification_requirement_ = 61 UserVerificationRequirement::kPreferred; 62 }; 63 64 } // namespace device 65 66 #endif // DEVICE_FIDO_AUTHENTICATOR_SELECTION_CRITERIA_H_ 67