Module: WebAuthn

Defined in:
lib/webauthn.rb,
lib/webauthn/error.rb,
lib/webauthn/encoder.rb,
lib/webauthn/version.rb,
lib/webauthn/credential.rb,
lib/webauthn/public_key.rb,
lib/webauthn/client_data.rb,
lib/webauthn/fake_client.rb,
lib/webauthn/u2f_migrator.rb,
lib/webauthn/configuration.rb,
lib/webauthn/security_utils.rb,
lib/webauthn/credential_entity.rb,
lib/webauthn/attestation_object.rb,
lib/webauthn/authenticator_data.rb,
lib/webauthn/credential_options.rb,
lib/webauthn/fake_authenticator.rb,
lib/webauthn/credential_rp_entity.rb,
lib/webauthn/attestation_statement.rb,
lib/webauthn/public_key_credential.rb,
lib/webauthn/authenticator_response.rb,
lib/webauthn/credential_user_entity.rb,
lib/webauthn/attestation_statement/tpm.rb,
lib/webauthn/attestation_statement/base.rb,
lib/webauthn/attestation_statement/none.rb,
lib/webauthn/credential_request_options.rb,
lib/webauthn/attestation_statement/apple.rb,
lib/webauthn/credential_creation_options.rb,
lib/webauthn/attestation_statement/packed.rb,
lib/webauthn/public_key_credential/entity.rb,
lib/webauthn/public_key_credential/options.rb,
lib/webauthn/attestation_statement/fido_u2f.rb,
lib/webauthn/public_key_credential/rp_entity.rb,
lib/webauthn/authenticator_assertion_response.rb,
lib/webauthn/attestation_statement/android_key.rb,
lib/webauthn/public_key_credential/user_entity.rb,
lib/webauthn/authenticator_attestation_response.rb,
lib/webauthn/public_key_credential_with_assertion.rb,
lib/webauthn/fake_authenticator/attestation_object.rb,
lib/webauthn/fake_authenticator/authenticator_data.rb,
lib/webauthn/public_key_credential/request_options.rb,
lib/webauthn/public_key_credential/creation_options.rb,
lib/webauthn/public_key_credential_with_attestation.rb,
lib/webauthn/attestation_statement/android_safetynet.rb,
lib/webauthn/attestation_statement/fido_u2f/public_key.rb,
lib/webauthn/authenticator_data/attested_credential_data.rb

Defined Under Namespace

Modules: AttestationStatement, Credential, SecurityUtils Classes: AttestationObject, AttestationStatementVerificationError, AttestationTrustworthinessVerificationError, AttestedCredentialDataFormatError, AttestedCredentialVerificationError, AuthenticatorAssertionResponse, AuthenticatorAttestationResponse, AuthenticatorData, AuthenticatorDataFormatError, AuthenticatorDataVerificationError, AuthenticatorResponse, ChallengeVerificationError, ClientData, ClientDataMissingError, Configuration, CredentialCreationOptions, CredentialEntity, CredentialOptions, CredentialRPEntity, CredentialRequestOptions, CredentialUserEntity, Encoder, Error, FakeAuthenticator, FakeClient, OriginVerificationError, PublicKey, PublicKeyCredential, PublicKeyCredentialWithAssertion, PublicKeyCredentialWithAttestation, RootCertificateFinderNotSupportedError, RpIdVerificationError, SignCountVerificationError, SignatureVerificationError, TokenBindingVerificationError, TypeVerificationError, U2fMigrator, UserPresenceVerificationError, UserVerifiedVerificationError, VerificationError

Constant Summary collapse

TYPE_PUBLIC_KEY =
"public-key"
VERSION =
"2.5.0"
TYPES =
{ create: "webauthn.create", get: "webauthn.get" }.freeze

Class Method Summary collapse

Class Method Details

.configurationObject


8
9
10
# File 'lib/webauthn/configuration.rb', line 8

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:


12
13
14
# File 'lib/webauthn/configuration.rb', line 12

def self.configure
  yield(configuration)
end

.credential_creation_options(rp_name: nil, user_name: "web-user", display_name: "web-user", user_id: "1") ⇒ Object


9
10
11
12
13
14
15
16
17
18
# File 'lib/webauthn/credential_creation_options.rb', line 9

def self.credential_creation_options(rp_name: nil, user_name: "web-user", display_name: "web-user", user_id: "1")
  warn(
    "DEPRECATION WARNING: `WebAuthn.credential_creation_options` is deprecated."\
    " Please use `WebAuthn::Credential.options_for_create` instead."
  )

  CredentialCreationOptions.new(
    rp_name: rp_name, user_id: user_id, user_name: user_name, user_display_name: display_name
  ).to_h
end

.credential_request_optionsObject


6
7
8
9
10
11
12
13
# File 'lib/webauthn/credential_request_options.rb', line 6

def self.credential_request_options
  warn(
    "DEPRECATION WARNING: `WebAuthn.credential_request_options` is deprecated."\
    " Please use `WebAuthn::Credential.options_for_get` instead."
  )

  CredentialRequestOptions.new.to_h
end

.generate_user_idObject


12
13
14
# File 'lib/webauthn.rb', line 12

def self.generate_user_id
  configuration.encoder.encode(SecureRandom.random_bytes(64))
end

.standard_encoderObject


6
7
8
# File 'lib/webauthn/encoder.rb', line 6

def self.standard_encoder
  @standard_encoder ||= Encoder.new
end