Class: WebAuthn::CredentialCreationOptions
- Inherits:
-
CredentialOptions
- Object
- CredentialOptions
- WebAuthn::CredentialCreationOptions
- Defined in:
- lib/webauthn/credential_creation_options.rb
Constant Summary collapse
- DEFAULT_RP_NAME =
"web-server"
Constants inherited from CredentialOptions
WebAuthn::CredentialOptions::CHALLENGE_LENGTH
Instance Attribute Summary collapse
-
#attestation ⇒ Object
Returns the value of attribute attestation.
-
#authenticator_selection ⇒ Object
Returns the value of attribute authenticator_selection.
-
#exclude_credentials ⇒ Object
Returns the value of attribute exclude_credentials.
-
#extensions ⇒ Object
Returns the value of attribute extensions.
Instance Method Summary collapse
-
#initialize(attestation: nil, authenticator_selection: nil, exclude_credentials: nil, extensions: nil, user_id:, user_name:, user_display_name: nil, rp_name: nil) ⇒ CredentialCreationOptions
constructor
A new instance of CredentialCreationOptions.
- #pub_key_cred_params ⇒ Object
- #rp ⇒ Object
- #to_h ⇒ Object
- #user ⇒ Object
Methods inherited from CredentialOptions
Constructor Details
#initialize(attestation: nil, authenticator_selection: nil, exclude_credentials: nil, extensions: nil, user_id:, user_name:, user_display_name: nil, rp_name: nil) ⇒ CredentialCreationOptions
Returns a new instance of CredentialCreationOptions.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/webauthn/credential_creation_options.rb', line 25 def initialize( attestation: nil, authenticator_selection: nil, exclude_credentials: nil, extensions: nil, user_id:, user_name:, user_display_name: nil, rp_name: nil ) super() @attestation = attestation @authenticator_selection = authenticator_selection @exclude_credentials = exclude_credentials @extensions = extensions @user_id = user_id @user_name = user_name @user_display_name = user_display_name @rp_name = rp_name end |
Instance Attribute Details
#attestation ⇒ Object
Returns the value of attribute attestation.
23 24 25 |
# File 'lib/webauthn/credential_creation_options.rb', line 23 def attestation @attestation end |
#authenticator_selection ⇒ Object
Returns the value of attribute authenticator_selection.
23 24 25 |
# File 'lib/webauthn/credential_creation_options.rb', line 23 def authenticator_selection @authenticator_selection end |
#exclude_credentials ⇒ Object
Returns the value of attribute exclude_credentials.
23 24 25 |
# File 'lib/webauthn/credential_creation_options.rb', line 23 def exclude_credentials @exclude_credentials end |
#extensions ⇒ Object
Returns the value of attribute extensions.
23 24 25 |
# File 'lib/webauthn/credential_creation_options.rb', line 23 def extensions @extensions end |
Instance Method Details
#pub_key_cred_params ⇒ Object
75 76 77 78 79 |
# File 'lib/webauthn/credential_creation_options.rb', line 75 def pub_key_cred_params configuration.algorithms.map do |alg_name| { type: "public-key", alg: COSE::Algorithm.by_name(alg_name).id } end end |
#rp ⇒ Object
81 82 83 |
# File 'lib/webauthn/credential_creation_options.rb', line 81 def rp @rp ||= CredentialRPEntity.new(name: rp_name || configuration.rp_name || DEFAULT_RP_NAME) end |
#to_h ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/webauthn/credential_creation_options.rb', line 47 def to_h = { challenge: challenge, pubKeyCredParams: pub_key_cred_params, timeout: timeout, user: { id: user.id, name: user.name, displayName: user.display_name }, rp: { name: rp.name } } if attestation [:attestation] = attestation end if authenticator_selection [:authenticatorSelection] = authenticator_selection end if exclude_credentials [:excludeCredentials] = exclude_credentials end if extensions [:extensions] = extensions end end |
#user ⇒ Object
85 86 87 |
# File 'lib/webauthn/credential_creation_options.rb', line 85 def user @user ||= CredentialUserEntity.new(id: user_id, name: user_name, display_name: user_display_name) end |