Skip to content

Conversation

@matteyu
Copy link
Contributor

@matteyu matteyu commented Jan 22, 2025

@matteyu matteyu changed the title [WIP] feat: add endpoints - authenticate [passkeys] feat: add endpoints - authenticate [passkeys] Jan 27, 2025
@matteyu matteyu changed the title feat: add endpoints - authenticate [passkeys] feat: add endpoints - authenticate [passkeys] - part 2 Jan 27, 2025
@matteyu matteyu changed the base branch from arc-937/embed-endpoints to development February 25, 2025 15:42
@vercel
Copy link

vercel bot commented Feb 25, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
embed-api ❌ Failed (Inspect) May 7, 2025 7:33am

@matteyu matteyu changed the base branch from development to arc-1133/row-level-security April 30, 2025 07:04
@matteyu matteyu changed the base branch from arc-1133/row-level-security to development April 30, 2025 17:53
@matteyu
Copy link
Contributor Author

matteyu commented May 2, 2025

Updated video of iframe test with passkeys

https://drive.google.com/file/d/1Imw5hxeI34aJm408QKV0xbAtLE_bUFpz/view?usp=drive_link

Draft PR updated to support passkeys in iframe: wanderwallet/Wander#793

}

// Fetch the user from the database
const userProfile = await prisma.userProfile.findUnique({
Copy link
Contributor

Choose a reason for hiding this comment

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

Auth tokens can never be generated on the client, as this allows an attacker to steal anyone else's session/account.

Copy link
Contributor Author

@matteyu matteyu May 6, 2025

Choose a reason for hiding this comment

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

The token gets generated on the server and get sent to the client so the signing key is still on the server. It just gets stored in localstorage on client side and sent back upon requests to the server


// If session doesn't exist, create it based on the token data
const newSessionId = decodedToken.session_id || crypto.randomUUID();
const newDeviceNonce = decodedToken.device_nonce || deviceNonce || crypto.randomUUID();
Copy link
Contributor

Choose a reason for hiding this comment

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

Device nonces should also be generated on the client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed crypto.randomUUID(); for server generation

email: string | null;
phone: string | null;
app_metadata: {
sessionData?: {
Copy link
Contributor

@Danziger Danziger May 4, 2025

Choose a reason for hiding this comment

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

Session data seems to be at the root, not nested inside app_metadata. app_metadata could be used to identify this sessions as originating from a passkeys authentication, as it usually contains something like this:

"app_metadata": {
    "provider": "twitter",
    "providers": [
      "twitter"
    ]
  }

However, if you fetch a session on the client, you'll session.user also contains an identities property. I'm not sure if manually setting the value of provider and providers will throw any error, as it's related to this: https://supabase.com/docs/guides/auth/auth-identity-linking

If that doesn't work, I guess it would make sense to set app_metadata.provider to the value that corresponds to email and password, as that's how we created those users anyway, and move the user details to user_metadata. This means that the client should not need to store any kind of data to know whether a session comes from a passkeys authentication or something else, as the session itself contains that information.

Copy link
Contributor Author

@matteyu matteyu May 6, 2025

Choose a reason for hiding this comment

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

good point. I restructured it so that it specifies passkey auth method in app data. I've tested it and it did not throw any errors when manually setting these values.

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.

4 participants