sidebase / nuxt-auth

Authentication built for Nuxt 3! Easily add authentication via OAuth providers, credentials or Email Magic URLs!
https://auth.sidebase.io
MIT License
1.29k stars 163 forks source link

Provider: Implement crypto-wallet-based authentication #467

Closed BracketJohn closed 8 months ago

BracketJohn commented 1 year ago

Describe the feature

Goal

Implement a wallet-based login.

Context

On one of our engagements we needed to implement authentication using chain-wallets. We would love to transfer it to this project to offer the same functionality to Nuxt 3 users for an easy entry into the crypto-space.

Providers in nuxt-auth generally have two components:

For our implementation here client-only + a reference server-side implementation should be sufficient. Later on we can think about providing server-side utilities, but that will also force us to think about default ways to specify DB-adapters and more.

Based on this scope-limitation using the local provider as an implementation example should be most helpful. Another interesting resource: @danielwinkelmann started on an implementation of a refresh provider in #373. The refresh provider is very similar to the local provider with the addition of a periodic token-refresh.

Other notes:

Assets

Related issue + implementation of ethereum based authentication: https://github.com/powerhouse-inc/switchboard-boilerplate/issues/52

Tasks

Additional information

No response

valiafetisov commented 1 year ago

Looking at the linked composables I don't think most of those (sign in, sign out, token management, etc) needs to be reimplemented in order to support "Sign-In with Ethereum" functionality. I would instead contribute a smaller abstraction (e.g. adapter/integration/provider, not sure what's the vocabulary here) – a relatively small part of code:

And I imagine that if it's just a provider, it can even live in a different repo/example implementation.

Do you see a technical/organisational problem with what I've described?

BracketJohn commented 1 year ago

Do you see a technical/organisational problem with what I've described?

Not at all! Proposal: Add a new playground-ethereum/ folder by cope-pasting the local playground. Then you have the freedom to in parallel:

In the end we'll have a full picture of what complexity stays on the users' app-side and what complexity will be moved into the module.

In the future or right in that PR we can then also discuss & move the balance of this abstraction further into the module or into the users' app.