Skip to content

Comments

feat: WebAuthn support#497

Merged
NathaelB merged 61 commits intoferriskey:mainfrom
hocman2:feat/webauthn
Nov 24, 2025
Merged

feat: WebAuthn support#497
NathaelB merged 61 commits intoferriskey:mainfrom
hocman2:feat/webauthn

Conversation

@hocman2
Copy link
Contributor

@hocman2 hocman2 commented Oct 10, 2025

Draft note:

This is a proposal for issue #314
The current implementation allows for creation and authentication of webauthn credentials through four new routes.

There are a lot of file changes but only a handful of files are interesting:

  • application/trident/mod: route backend implementation
  • application/http/trident/handlers: new routes

Codebase change

This feature required to add columns to the auth_sessions and credentials tables.

More importantly, I had to switch CredentialData from a struct to an enum because webauthn credentials required a completely different data model.
I updated all places where credential_data was used, which required some function signature changes.
Namely, the HasherRepository interface now requires two explicit parameters for hash_iterations and algorithm, this isn't all so bad as the hasher's interface doesn't need to be aware of anything going on with Credentials anymore.

This approach isn't ideal though. For one it makes using credential_data more tedious than it used to be as you need to explicitly reject any unexpected credential type (generally through an ISE) and two it only patches a broader issue being that Credential should probably be an enum type altogether.

I've also rebased against the latest main

Implementation

The feature uses webauthn-rs under-the-hood for all spec compliance.

Testing

I've run a few successful normal auth flows (registering and authenticating multiple times on the same account)
The server correctly consumes any issued challenge with both successful and failed attempts, preventing replay attacks.

@hocman2 hocman2 marked this pull request as ready for review October 27, 2025 09:53
@hocman2 hocman2 requested a review from NathaelB as a code owner October 27, 2025 09:53
use super::api_success::ApiSuccess;

#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Response<T: Serialize + PartialEq> {
Copy link
Member

@NathaelB NathaelB Oct 27, 2025

Choose a reason for hiding this comment

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

Why remove PartialEq derive ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I initially PRed deriving PartialEq on some webauthn_rs types to prevent this from happening but after a long debate with the owner this ended up being refused.

My only two solutions were to either implement manually PartialEq on the response types, which would have been a boilerplate non-sense; or to remove the PartialEq requirement on Response which does not appear to be needed, but I understand why it could exist (and I forgot to remove the derive traits on Response itself)
My thought process was that in the future we could be returning responses of deeply nested types that don't necessarily implement PartialEq and this eases up the process a bit.

We can reverse this if you want but that would require to reimplement a lot (almost all actually) of WebAuthn spec types on our end and just do a 1:1 conversion between ours and the webauthn_rs crate's.
This does have the advantage of letting us control which trait we derive or not but it could also backfire into a maintenance nightmare on crate update.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And I do agree that PartialEq is such a primitive operation that it should be derived whenever possible

Copy link
Member

Choose a reason for hiding this comment

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

Okay no problem, if this operation don't make problem, then...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems harmless, even when running tests

@NathaelB
Copy link
Member

Really great work

Maybe after fix pre-commit , we can merge it

@hocman2
Copy link
Contributor Author

hocman2 commented Oct 28, 2025

Sorry I have the bad habit of pushing immediately after commit
I actually want to run some tests after applying clippy changes so dont merge immediayely

Edit: pre-commit failed anyway 😢

@hocman2
Copy link
Contributor Author

hocman2 commented Oct 28, 2025

That was messy but it should be good

@NathaelB NathaelB self-requested a review October 31, 2025 18:50
Copy link
Member

@NathaelB NathaelB left a comment

Choose a reason for hiding this comment

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

LGTM

@NathaelB
Copy link
Member

It's good for me , but for merged that it's necessary to verify your commit with a verified signatures

@hocman2
Copy link
Contributor Author

hocman2 commented Nov 2, 2025

Should I sign every commit in the branch ?

@NathaelB
Copy link
Member

NathaelB commented Nov 3, 2025

Hello , sorry for the time, I'll be at the Alasca Summit for the next few days.

Maybe you can try for 1 commit, else you can rebase all commits and signed it.

@hocman2
Copy link
Contributor Author

hocman2 commented Nov 6, 2025

Ok i've setup signing as well as complying with the latest credentialtype changes. Tell me if it's enough or not

@NathaelB
Copy link
Member

NathaelB commented Nov 6, 2025

Normally, it's good !

@NathaelB
Copy link
Member

To merge, all commits must be signed. You can do a rebase to achieve this.

@hocman2
Copy link
Contributor Author

hocman2 commented Nov 20, 2025

Alright I'll do that either this week end or next week

@NathaelB
Copy link
Member

Hi @hocman2 you can rebase your branch ?

@NathaelB NathaelB moved this from In progress to In review in alpha release Nov 24, 2025
@hocman2
Copy link
Contributor Author

hocman2 commented Nov 24, 2025

Hi @hocman2 you can rebase your branch ?

Yes, had unexpected events this week end so I could allocate less time than I thought to the task.
I've done the rebase but I'm having a bug with the server, IDK if it was introduced by the rebase or a new commit.
Since I need to do some testing before sending a new PR i'll have to investigate that

@NathaelB
Copy link
Member

Hi @hocman2 you can rebase your branch ?

Yes, had unexpected events this week end so I could allocate less time than I thought to the task. I've done the rebase but I'm having a bug with the server, IDK if it was introduced by the rebase or a new commit. Since I need to do some testing before sending a new PR i'll have to investigate that

Okay no problem !

@hocman2
Copy link
Contributor Author

hocman2 commented Nov 24, 2025

Ok should be good now, the bug actually highlighted syntax errors in the migrations I had written so it's win win

@NathaelB
Copy link
Member

Ok should be good now, the bug actually highlighted syntax errors in the migrations I had written so it's win win

Okay, so it's good for merge ?

@hocman2
Copy link
Contributor Author

hocman2 commented Nov 24, 2025

Ok should be good now, the bug actually highlighted syntax errors in the migrations I had written so it's win win

Okay, so it's good for merge ?

yes

@NathaelB NathaelB merged commit 3bf016e into ferriskey:main Nov 24, 2025
8 checks passed
@github-project-automation github-project-automation bot moved this from In review to Done in alpha release Nov 24, 2025
@NathaelB
Copy link
Member

merged ! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants