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

Implement Solana Sign-In #1

Open
alfonso-paella opened this issue Dec 4, 2021 · 2 comments
Open

Implement Solana Sign-In #1

alfonso-paella opened this issue Dec 4, 2021 · 2 comments
Assignees

Comments

@alfonso-paella
Copy link
Contributor

alfonso-paella commented Dec 4, 2021

We're looking to implement Solana sign-in for our project.

We need a client-side Javascript library + a server side nodejs library that implement sign-in with Solana, and use Firebase Auth for persistent auth sessions after sign in.

Here's the full list of steps we expect this to entail:

  1. Create a sign-in entry point

  2. When user initiates sign-in:
    1.1 User "connects" with their wallet on the browser, via wallet adapter, and we get their pubkey
    1.2 client sends pubkey to server: getauthchallenge/pubkey
    1.3 Server generates a random nonce and stores in a temporary DB (firestore) the (nonce, pubkey) combination, with some TTL (e.g. of 1hr).
    1.4 Server returns "nonce" to the client

  3. On the client, take the nonce and have the user sign it with their wallet (e.g. Phantom). Note that the "nonce" actually also contains a user readable message on the lines of "Sign this message with your wallet to sign in to desolate.space. Nonce=28342765"

  4. Send the signed payload back to the server: completeauthchallenge/(pubkey, payload, payload signature)
    3.1 Extract nonce from payload
    3.2 Lookup pubkey and TTL from DB, based off the nonce
    3.3 Verify the payload contains "Sign this message with your wallet to sign in to desolate.space"
    3.4 Verify signature corresponds to pubkey and isn't expired
    3.5 If it's all correct, generate a JWT session token with Firebase (Firebase Auth Custom Tokens), and send it back to client

  5. Client receives Firebase Auth Custom token
    4.1. Call FirebaseAuth#signInWithCustomAuth(): this creates a refresh token (persistent session) which gets stored locally on the browser storage. And from this, access tokens are derived automatically every hour or so
    4.2. Use firebase auth libraries for verifying access both on the client as well as on the server side

Links:

@alfonso-paella
Copy link
Contributor Author

alfonso-paella commented Dec 6, 2021

@alfonso-paella
Copy link
Contributor Author

Library for crypto: https://github.com/dchest/tweetnacl-js

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

No branches or pull requests

2 participants