Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to webauthn 1.6.0 #52

Merged
merged 15 commits into from
May 14, 2024
Merged

Upgrade to webauthn 1.6.0 #52

merged 15 commits into from
May 14, 2024

Conversation

Natim
Copy link
Collaborator

@Natim Natim commented Sep 22, 2022

No description provided.

@Natim Natim force-pushed the chore/upgrade-webauthn-1.6.0 branch from 9d6faf4 to 84968b2 Compare September 23, 2022 11:01
@dunderrrrrr
Copy link

Is this about to be merged into main when checks pass? @justinmayer
Would much appreciate webauthn version 1.6.0 😄

@Natim Natim force-pushed the chore/upgrade-webauthn-1.6.0 branch from 5d36528 to 4b5bd91 Compare September 28, 2022 10:06
@Natim Natim marked this pull request as ready for review September 28, 2022 10:06
@Natim
Copy link
Collaborator Author

Natim commented Sep 28, 2022

@dunderrrrrr did you had a chance to test kagi with this new branch? I am a bit worried that the migration is not going to be easy.

@Natim Natim force-pushed the chore/upgrade-webauthn-1.6.0 branch from 4b5bd91 to ae2fa0d Compare September 28, 2022 10:09
@dunderrrrrr
Copy link

@Natim not yet, ill give it a shot when I have time. Thanks!

@justinmayer
Copy link
Owner

justinmayer commented Sep 28, 2022 via email

Comment on lines +91 to +92
_authenticator_selection = AuthenticatorSelectionCriteria()
_authenticator_selection.user_verification = UserVerificationRequirement.DISCOURAGED
Copy link

@inbalzelinger inbalzelinger Nov 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to allow the user to register new usb nfc yubikey, one that it's pin code wasn't defined before on this specific browser you should define the
_authenticator_selection.resident_key=ResidentKeyRequirement.PREFERRED see

formData.set("csrf_token", token);

const resp = await fetch(
"/kagi/api/verify-credential-info/", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not use hardcoded URLs, instead use window.Kagi.verify_credential_info
Same for other hardcoded URLs in this file.

@justinmayer
Copy link
Owner

After testing the contents of this upgrade-webauthn-1.6.0 branch on an existing production application that relocates the Kagi views from its default path, I encountered an error when trying to add a WebAuthn key. I finally found the time to reproduce this error using the bundled test project, which I will document here.

First, starting on the current main branch, I followed the steps in the README to set up the test project, including running the initial migrations, creating a superuser, etc. Then I logged into http://localhost:8000 using Firefox 112.0.1, added a new WebAuthn key successfully, logged out, logged back in using the WebAuthn key, and finally removed the WebAuthn key. In short, I confirmed that basic WebAuthn behavior functions correctly in the current main branch. In a separate terminal session and virtual environment, I switched to the upgrade-webauthn-1.6.0 branch, installed the upgraded dependencies and code via poetry upgrade && poetry install, ran migrations, and confirmed that all of the above steps continue to function as expected. So far, so good.

Then, switching back to my other terminal session running the current main branch, I modified testproj/testproj/urls.py, adding these imports…

from kagi.views import api as kagi_api_views
from kagi.views.login import KagiLoginView

… these urlpatterns

path("login/", KagiLoginView.as_view(), name="login"),
path("settings/security/", include("kagi.urls", namespace="kagi")),

… and I commented out this line, which is obviated by the line above:

# path("kagi/", include("kagi.urls", namespace="kagi")),

After making these changes, I confirmed that all of the above WebAuthn-related behavior continues to function as expected on the current main branch, even though the Kagi views have been relocated from /kagi/ to /settings/security/.

However, when I switch back to the upgrade-webauthn-1.6.0 branch, attempting to add a WebAuthn key results in the following error in the browser console:

Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

    ProvisionWebAuthn http://localhost:8000/static/kagi/webauthn.js:211
    AsyncFunctionThrow self-hosted:814
    (Async: async)
    doWebAuthn http://localhost:8000/static/kagi/webauthn.js:47

GET | http://localhost:8000/kagi/api/begin-activate/
Status: 404 Not Found

In short, it seems the new branch depends on the /kagi/ prefix in a way that the current main branch does not, which at least for me feels like a regression.

@Natim: Do you have any ideas about what is going on here, and perhaps how it might be resolved?

(Copying @apollo13, @carltongibson & @MarkusH)

@rphlo
Copy link
Contributor

rphlo commented May 31, 2023

After testing the contents of this upgrade-webauthn-1.6.0 branch on an existing production application that relocates the Kagi views from its default path, I encountered an error when trying to add a WebAuthn key. I finally found the time to reproduce this error using the bundled test project, which I will document here.

First, starting on the current main branch, I followed the steps in the README to set up the test project, including running the initial migrations, creating a superuser, etc. Then I logged into http://localhost:8000 using Firefox 112.0.1, added a new WebAuthn key successfully, logged out, logged back in using the WebAuthn key, and finally removed the WebAuthn key. In short, I confirmed that basic WebAuthn behavior functions correctly in the current main branch. In a separate terminal session and virtual environment, I switched to the upgrade-webauthn-1.6.0 branch, installed the upgraded dependencies and code via poetry upgrade && poetry install, ran migrations, and confirmed that all of the above steps continue to function as expected. So far, so good.

Then, switching back to my other terminal session running the current main branch, I modified testproj/testproj/urls.py, adding these imports…

from kagi.views import api as kagi_api_views

from kagi.views.login import KagiLoginView

… these urlpatterns

path("login/", KagiLoginView.as_view(), name="login"),

path("settings/security/", include("kagi.urls", namespace="kagi")),

… and I commented out this line, which is obviated by the line above:

# path("kagi/", include("kagi.urls", namespace="kagi")),

After making these changes, I confirmed that all of the above WebAuthn-related behavior continues to function as expected on the current main branch, even though the Kagi views have been relocated from /kagi/ to /settings/security/.

However, when I switch back to the upgrade-webauthn-1.6.0 branch, attempting to add a WebAuthn key results in the following error in the browser console:


Uncaught (in promise) SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data



    ProvisionWebAuthn http://localhost:8000/static/kagi/webauthn.js:211

    AsyncFunctionThrow self-hosted:814

    (Async: async)

    doWebAuthn http://localhost:8000/static/kagi/webauthn.js:47



GET | http://localhost:8000/kagi/api/begin-activate/

Status: 404 Not Found

In short, it seems the new branch depends on the /kagi/ prefix in a way that the current main branch does not, which at least for me feels like a regression.

See my earlier comment that point out the origin of this issue.

@justinmayer
Copy link
Owner

@rphlo: Around the time of your previous comment, I tried using window.Kagi.verify_credential_info, but I could not figure out how to use it to resolve the problem. Is there any chance you could propose a specific diff that would successfully resolve the problem in question?

@rphlo
Copy link
Contributor

rphlo commented Jun 1, 2023

@rphlo: Around the time of your previous comment, I tried using window.Kagi.verify_credential_info, but I could not figure out how to use it to resolve the problem. Is there any chance you could propose a specific diff that would successfully resolve the problem in question?

I have successfully ran this branch with the following change in webauthn.js rphlo@4db7f51 (this includes some linting too)

@apollo13
Copy link
Collaborator

apollo13 commented Jun 1, 2023

Hi @rphlo, thank you so much for this. I will pulling your chances into this branch shortly and will start testing.

@apollo13 apollo13 force-pushed the chore/upgrade-webauthn-1.6.0 branch from 20ba30a to 679c419 Compare June 1, 2023 11:10
pyproject.toml Outdated Show resolved Hide resolved
@MarkusH
Copy link
Collaborator

MarkusH commented Jun 1, 2023

@rphlo: Around the time of your previous comment, I tried using window.Kagi.verify_credential_info, but I could not figure out how to use it to resolve the problem. Is there any chance you could propose a specific diff that would successfully resolve the problem in question?

As a follow-up to this, I opened #65

@rphlo
Copy link
Contributor

rphlo commented Jun 1, 2023

@rphlo: Around the time of your previous comment, I tried using window.Kagi.verify_credential_info, but I could not figure out how to use it to resolve the problem. Is there any chance you could propose a specific diff that would successfully resolve the problem in question?

As a follow-up to this, I opened #65

@MarkusH This is an issue I also had in my project. I fixed it somehow similarly, however this is something that I believe is outside the scope of this PR and can be fixed in separate one as it affect also other branches.

@MarkusH
Copy link
Collaborator

MarkusH commented Jun 1, 2023

@rphlo: Around the time of your previous comment, I tried using window.Kagi.verify_credential_info, but I could not figure out how to use it to resolve the problem. Is there any chance you could propose a specific diff that would successfully resolve the problem in question?

As a follow-up to this, I opened #65

@MarkusH This is an issue I also had in my project. I fixed it somehow similarly, however this is something that I believe is outside the scope of this PR and can be fixed in separate one as it affect also other branches.

Yes, absolutely!

@MarkusH MarkusH linked an issue Jun 1, 2023 that may be closed by this pull request
@justinmayer justinmayer force-pushed the chore/upgrade-webauthn-1.6.0 branch from 1d5f715 to d919efb Compare May 14, 2024 14:36
@justinmayer justinmayer changed the title Upgrade to webauthn 1.6.0 Upgrade to webauthn 1.6.0 May 14, 2024
Copy link
Owner

@justinmayer justinmayer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many sincere thanks to @Natim for all his work on this endeavor, as well as to everyone else who helped review and improve it! 🌟

@justinmayer justinmayer merged commit 2393273 into main May 14, 2024
15 checks passed
@justinmayer justinmayer deleted the chore/upgrade-webauthn-1.6.0 branch May 14, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Demo instructions invoke migrate no such file or directory
7 participants