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 Sign In, Sign Up and Options methods support - NEW #952

Open
wants to merge 8 commits into
base: feat/webauthn/base
Choose a base branch
from

Conversation

victorbojica
Copy link

ONLY REVIEW REQUIRED. NOTHING TESTED YET.

Summary of change

Implement WebAuthN support according to:
https://docs.google.com/document/d/1G7tO9_dSNi8wur3ajGg4pq-wiHatKDbHv2sBt-uSbQg/edit#heading=h.olee876uqu8a

Related

Check #942 for more feedback

Test Plan

No testing at the moment.

Documentation changes

Will have to add WebAuthN recipe documentation

Checklist for important updates

  • Changelog has been updated
  • coreDriverInterfaceSupported.json file has been updated (if needed)
    • Along with the associated array in lib/ts/version.ts
  • frontendDriverInterfaceSupported.json file has been updated (if needed)
  • Changes to the version if needed
    • In package.json
    • In package-lock.json
    • In lib/ts/version.ts
  • Had run npm run build-pretty
  • Had installed and ran the pre-commit hook
  • If new thirdparty provider is added,
    • update switch statement in recipe/thirdparty/providers/configUtils.ts file, createProvider function.
    • add an icon on the user management dashboard.
  • Issue this PR against the latest non released version branch.
    • To know which one it is, run find the latest released tag (git tag) in the format vX.Y.Z, and then find the latest branch (git branch --all) whose X.Y is greater than the latest released tag.
    • If no such branch exists, then create one from the latest released branch.
  • If have added a new web framework, update the add-ts-no-check.js file to include that
  • If added a new recipe / api interface, then make sure that the implementation of it uses NON arrow functions only (like someFunc: function () {..}).
  • If added a new recipe, then make sure to expose it inside the recipe folder present in the root of this repo. We also need to expose its types.
  • If added a new entry point, then make sure that it is importable by adding it to the exports in package.json

Remaining TODOs for this PR

  • Check support for other authenticators
  • Account recovery flow
  • Options testing
  • Sign In testing
  • Sign Up testing
  • Multiple authenticators testing

@victorbojica victorbojica changed the title Feat/webauthn/basic methods feat: WebAuthN Sign In, Sign Up and Options methods support - NEW Oct 17, 2024
lib/ts/recipe/multifactorauth/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Outdated Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/multifactorauth/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Outdated Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Outdated Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Outdated Show resolved Hide resolved
lib/ts/recipe/webauthn/types.ts Outdated Show resolved Hide resolved
| { status: "GENERATED_OPTIONS_ID_MISSING_ERROR" }
>;

verifyCredentials(input: {
Copy link
Member

Choose a reason for hiding this comment

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

this function has identical func signature as registerPasskeys. Are both, this and the other function needed?

Copy link
Author

Choose a reason for hiding this comment

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

yes. one logs in the user, the other adds a credential to the database

Copy link
Member

Choose a reason for hiding this comment

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

Thats too high level of an explanation.. what will be the exact diff between the implementation of them? Its not like the signIn will create a session - so it doesn't "log in" the user.

lib/ts/recipe/webauthn/types.ts Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Oct 18, 2024

Deploying supertokens-node-pr-check-for-edge-function-compat with  Cloudflare Pages  Cloudflare Pages

Latest commit: ced57b1
Status: ✅  Deploy successful!
Preview URL: https://ad4fff7f.supertokens-node-b95.pages.dev

View logs

}): Promise<
{ status: "OK"; user: User; recipeUserId: RecipeUserId } | { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" }
>;
};
Copy link
Member

Choose a reason for hiding this comment

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

need more functions to have CRUD operation on credential IDs? How will a

Copy link
Member

Choose a reason for hiding this comment

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

@victorbojica, you missed this comment?

@@ -154,6 +154,7 @@ export type GetPhoneNumbersForFactorsFromOtherRecipesFunc = (

export const FactorIds = {
EMAILPASSWORD: "emailpassword",
WEBAUTHN: "webauthn",
Copy link
Member

Choose a reason for hiding this comment

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

this will also result in changes to the existing loginMethodsGET API in multitenancy recipe.

Copy link
Author

Choose a reason for hiding this comment

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

done

email: string;
}
| {
session: SessionContainerInterface;
Copy link
Member

Choose a reason for hiding this comment

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

when is only a session needed? And how will we get the email from the session? What if the currently logging in user has no email, or what if the currently logged in user has multiple emails (cause they are a primary user with multiple emails)

Copy link
Author

Choose a reason for hiding this comment

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

If there is no email, it will throw. I've added the error. As for when there are multiple emails i was thinking of only using the email from the webauthn login method. Basically allowing register passkey to be used if the user is logged in with webauthn. If there is no session, they should pass one of the other options...

What do you think ?

}
| { status: "EMAIL_ALREADY_EXISTS_ERROR" }
// when the attestation is checked and is not valid or other cases in whcih the authenticator is not correct
| { status: "INVALID_AUTHENTICATOR_ERROR" }
Copy link
Member

Choose a reason for hiding this comment

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

is there nothing else we need to tell the user when this error happens? Like why was the authenticator invalid?

userId: string;
}
| { status: "WRONG_CREDENTIALS_ERROR" }
| { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" }
Copy link
Member

Choose a reason for hiding this comment

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

shouldnt this also have INVALID_AUTHENTICATOR_ERROR as an output?

| { status: "GENERATED_OPTIONS_ID_MISSING_ERROR" }
>;

verifyCredentials(input: {
Copy link
Member

Choose a reason for hiding this comment

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

Thats too high level of an explanation.. what will be the exact diff between the implementation of them? Its not like the signIn will create a session - so it doesn't "log in" the user.

recipeUserId: RecipeUserId;
}
| { status: "EMAIL_ALREADY_EXISTS_ERROR" }
| { status: "WRONG_CREDENTIALS_ERROR" }
Copy link
Member

Choose a reason for hiding this comment

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

need INVALID_AUTHENTICATOR_ERROR here?

}): Promise<
{ status: "OK"; user: User; recipeUserId: RecipeUserId } | { status: "RECOVER_ACCOUNT_TOKEN_INVALID_ERROR" }
>;
};
Copy link
Member

Choose a reason for hiding this comment

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

@victorbojica, you missed this comment?

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.

3 participants