Skip to content

Commit

Permalink
Fix axum example for credential creation (#361)
Browse files Browse the repository at this point in the history
While investigating #351 I noticed that the `excludeCredentials` id's were still in base64url and which was failing validation in 1Password. Here I mirror the same modifications done to the `allowCredentials` list.

This also adds an optional chaining to the `allowCredentials` list in
the request options.
  • Loading branch information
Progdrasil authored Oct 5, 2023
1 parent 13dc8b6 commit 7dc3eed
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tutorial/server/axum/assets/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ function register () {
.then(credentialCreationOptions => {
credentialCreationOptions.publicKey.challenge = Base64.toUint8Array(credentialCreationOptions.publicKey.challenge);
credentialCreationOptions.publicKey.user.id = Base64.toUint8Array(credentialCreationOptions.publicKey.user.id);
credentialCreationOptions.publicKey.excludeCredentials?.forEach(function (listItem) {
listItem.id = Base64.toUint8Array(listItem.id)
});

return navigator.credentials.create({
publicKey: credentialCreationOptions.publicKey
Expand Down Expand Up @@ -57,7 +60,7 @@ function login() {
.then(response => response.json())
.then((credentialRequestOptions) => {
credentialRequestOptions.publicKey.challenge = Base64.toUint8Array(credentialRequestOptions.publicKey.challenge);
credentialRequestOptions.publicKey.allowCredentials.forEach(function (listItem) {
credentialRequestOptions.publicKey.allowCredentials?.forEach(function (listItem) {
listItem.id = Base64.toUint8Array(listItem.id)
});

Expand Down

0 comments on commit 7dc3eed

Please sign in to comment.