Authen::WebAuthn(3pm) | User Contributed Perl Documentation | Authen::WebAuthn(3pm) |
Authen::WebAuthn - A library to add Web Authentication support to server applications
version 0.001
This module lets you validate WebAuthn registration and authentication responses.
Currently, it does not handle the generation of registration and authentication requests.
The transmission of requests and responses from the application server to the user's browser, and interaction with the WebAuthn browser API is also out of scope and could be handled by a dedicated JS library.
To register a new device:
# Obtain registration response from web browser # Then, my $webauthn_rp = Authen::WebAuthn->new( rp_id => "app.example.com", origin => "https://app.example.com" ); my $registration_result = eval { $webauthn_rp->validate_registration( challenge_b64 => ... , requested_uv => ... , client_data_json_b64 => ... , attestation_object_b64 => ... , token_binding_id_b64 => ... , ) }; if ($@) { die "Error validating registration: $@"; }
To authenticate a user:
# Obtain authentication response from web browser # Then, my $webauthn_rp = Authen::WebAuthn->new( rp_id => "app.example.com", origin => "https://app.example.com" ); my $validation_result = eval { $webauthn_rp->validate_assertion( challenge_b64 => ..., credential_pubkey_b64 => ..., stored_sign_count => ..., requested_uv => ..., client_data_json_b64 => ..., authenticator_data_b64 => ..., signature_b64 => ..., extension_results => ..., token_binding_id_b64 => ..., ) }; if ($@) { die "Error validating authentication: $@"; }
The identifier of your Relying Party. Usually, this is set to the domain name over which your application is accessed (app.example.com).
The origin, as defined by the HTML standard, that your Relying Party is expecting to find in registration or authentication responses. This must contain the scheme and port of your application, but no path (http://app.example.com:8080 or https://app.example.com)
This method validates the registration response emitted by the authenticator.
It takes the following named arguments
This method croaks on errors. If the registration was successful, it returns a hashref with the following subkeys:
This information is supposed to be persisted in the Relying Party, usually in some sort of database
This method validates the registration response emitted by the authenticator.
It takes the following named arguments
This method croaks on errors. If the registration was successful, it returns a hashref with the following subkeys:
my $cose_b64 = Authen::WebAuthn::convert_raw_ecc_to_cose($u2f_b64);
This method takes the base64url-encoded raw ECC key (U2F format) and converts it to a base64url-encoded COSE representation. It can be useful for converting existing U2F device registration to WebAuthen device registrations in your Relying Party.
This module only supports the "None" attestation type at the moment, which means Relying Parties cannot have a strong guarantee of the authenticator's security properties. This makes it possible for users to register weak authenticators.
Because of that, is it not recommended to use this module in passwordless authentication scenarios. However, it should be good enough for using security keys as a second factor.
This limitation may be addressed in a future version.
Maxime Besson <mbesson@cpan.org>
This software is copyright (c) 2022 by Maxime Besson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2022-02-09 | perl v5.34.0 |