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

feat(webauthn): make webauthn params configurable #48

Merged
merged 13 commits into from
Apr 24, 2024

Conversation

shentschel
Copy link
Collaborator

@shentschel shentschel commented Feb 26, 2024

  • add attachment, attestation preference and resident key requirement params to create and update tenant endpoints
  • add fallback values when params are not provided
  • add migrations for new fields in webauthn config in database
  • reflect changes in README.md and admin spec

Closes: #45, #50

Stefan Jacobi added 3 commits February 26, 2024 09:25
* add attachment, attestation preference and resident key requirement params to create and update tenant endpoints
* add fallback values when params are not provided
* add migrations for new fields in webauthn config in database
* reflect changes in README.md and admin spec

Closes: #45
* add login init dto with user_id as optional param
* extend service to switch to BeginLogin /ValidateLogin when user_id was given
* extend database to persist login state in sessiondata for login/finalize
* extend openapi spec to reflect optional user_id parameter for login/initialize

Closes: #33
* add config for mfa passkeys
* add endpoints for mfa passkeys

TODO: add docs

Closes: #45
Copy link
Contributor

@FreddyDevelop FreddyDevelop left a comment

Choose a reason for hiding this comment

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

Not tested the PR, but here is what I found just looking at the code.

The admin API spec does not reflect the changes with MFA webauthn config.
The public API spec does not reflect the MFA changes, there are no routes with /mfa

server/api/dto/admin/request/webauthn.go Outdated Show resolved Hide resolved
server/api/dto/request/requests.go Outdated Show resolved Hide resolved
server/api/handler/mfa_login.go Outdated Show resolved Hide resolved
server/api/handler/mfa_login.go Outdated Show resolved Hide resolved
server/api/middleware/webauthn.go Outdated Show resolved Hide resolved
server/api/router/main.go Outdated Show resolved Hide resolved
server/api/router/main.go Outdated Show resolved Hide resolved
server/api/router/main.go Outdated Show resolved Hide resolved
@FreddyDevelop
Copy link
Contributor

Also a flag or indication that a credential can only be used as a MFA credential is missing. Currently you can use a credential that was created as MFA for a passkey login.

* mfa config has now its own database table
* mfa config does not require RP config anymore
* webauthn client for mfa uses rp from passkey config
* update openapi specs to reflect changes

Closes: #45
@shentschel
Copy link
Collaborator Author

I updated all findings + openapi spec and added the missed mfa flag

Stefan Jacobi added 2 commits March 25, 2024 15:59
* change attestation default mode from 'none' to 'direct'

Closes: #45
Copy link
Contributor

@FreddyDevelop FreddyDevelop left a comment

Choose a reason for hiding this comment

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

When calling /mfa/registration/initialize the options are missing the attachment.

When trying to use a security key at /mfa/login/finalize I always get an error {"title":"failed to get user handle","details":"user not found","status":401}. When using a credential that was created through the passkey endpoints I don't get this error.

server/api/dto/admin/request/webauthn.go Outdated Show resolved Hide resolved
server/api/handler/mfa_login.go Outdated Show resolved Hide resolved
server/api/handler/mfa_login.go Outdated Show resolved Hide resolved
server/api/handler/mfa_login.go Outdated Show resolved Hide resolved
server/api/handler/mfa_login.go Outdated Show resolved Hide resolved
server/api/services/transaction_service.go Outdated Show resolved Hide resolved
server/api/services/login_service.go Outdated Show resolved Hide resolved
server/api/dto/admin/request/config.go Outdated Show resolved Hide resolved
server/api/handler/login.go Outdated Show resolved Hide resolved
Stefan Jacobi added 2 commits April 3, 2024 15:59
* make MFA config optional for backwards compatibility
* rename some variables for better clarity
* add audit log types for MFA login for better distinction
* add missing attachment option to mfa client
* add api key vs tenant secrets check for mfa/non-discover login

Closes: #45
@shentschel
Copy link
Collaborator Author

When calling /mfa/registration/initialize the options are missing the attachment.

When trying to use a security key at /mfa/login/finalize I always get an error {"title":"failed to get user handle","details":"user not found","status":401}. When using a credential that was created through the passkey endpoints I don't get this error.

I fixed all findings but was unable to reproduce your 401 error. I do not own a security key so I tried to reproduce it with an iPhone which worked fine.

@FreddyDevelop
Copy link
Contributor

I fixed all findings but was unable to reproduce your 401 error. I do not own a security key so I tried to reproduce it with an iPhone which worked fine.

You can use the Chrome Virtual Authenticator to test it.
Create a new virtual authenticator with protocol: ctap2, transport: usb, supportsResidentKeys: true and supportsUserVerifcation: true. Then create a new mfa credential and try to login with that new credential and you will get the error.

@shentschel
Copy link
Collaborator Author

shentschel commented Apr 3, 2024

I don't know if my attachment changes fixed them. but it works on my side:

Screen.Recording.2024-04-03.at.16.39.23.mov

Edit: I think I found a big I have to fix and then test again. I tried the new MFA optional mechanism at the same time. And while looking into the code I think I made a copy paste error when creating the default MFA config (using all webauthn parameters from passkey config instead of defaults when mfa config is missing in dto)

shentschel and others added 4 commits April 3, 2024 19:41
use mfa default params instead of passkey dto ones when creating a mfa default config on admin operations `create tenant` or `update config`
Use sessionData userId as userhandle when login is MFA or non-discoverable.
Also check if credential is in allowed list

Closes: #45
credential check will be done by go-webauthn lib

Closes: #45
Copy link
Contributor

@FreddyDevelop FreddyDevelop left a comment

Choose a reason for hiding this comment

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

When a user has one passkey and one 2FA credential and /login/initialize is called with the userID in the body, the 2FA credential is included in the allowCredentials list. This leads to an uncool UX for the user. The 2FA credential ID should not be returned for passkey logins.

server/api/helper/tenant_helper.go Outdated Show resolved Hide resolved
spec/passkey-server-admin.yaml Outdated Show resolved Hide resolved
spec/passkey-server-admin.yaml Outdated Show resolved Hide resolved
* remove mfa credentials from allowedCredentials when using non mfa routes
* for good measure also remove mfa credentials from FindCredentialById when used on Non-MFA routes
* rename CreateApiKeyError to CheckApiKey
* increase versions of openapi spec
* change defaults for mfa config object in admin spec
* cleanup: remove unused methods from handler/webauthn.go

Closes: #45
@FreddyDevelop FreddyDevelop merged commit 442450c into main Apr 24, 2024
4 checks passed
@FreddyDevelop FreddyDevelop deleted the feat/45-make-webauthn-params-configurable branch April 24, 2024 07:59
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.

Make WebAuthn params configurable
2 participants