Giter Club home page Giter Club logo

web3-auth's Introduction

Solana Wallet Auth: A FullStack example

This example uses Solana's wallet adapter to sign messages and verifies their signatures on the backend, allowing for a lean way to authenticate users without the need for web2 credentials like email/password combinations or social providers, in this scenario all you have to do is connect your wallet and sign interaction messages to be properly authenticated.

How to run

Backend

cd wallet-backend
yarn && yarn dev

Frontend

cd wallet-frontend
yarn && yarn dev

Technology stack for this example

Most of the technologies used in this example are production ready, however, be sure to check them and remember to switch LowDB for a proper database.

Backend

  • NodeJS, Express, Typescript, LowDB (Local JSON file, only for testing), TweetNaCL.
  • GraphQL example coming soon.

Frontend

  • React, Typescript, Vite, Solana-Wallet-Adapter, Tailwind.

Notes

Validation on the backend happens using the library tweetnacl, but some additional checks were added, like action and message expiration.

The files you want to check are:

  • @wallet-backend/src/middleware/web3Auth.ts
  • @wallet-frontend/src/lib/api/web3Posts.ts

Where web3Auth.ts defines a simple, yet powerful authorization middleware that extracts the authorization headers and validates, then parses the message to perform some additional checks and the web3Posts.ts axios client exemplifies a good set of UX patterns, like reusing a token for "skip" requests (Requests that skip action checks).

Here's a diagram of how simplified is this authentication method

arch

Reference read

web3-auth's People

Contributors

kevinrodriguez-io avatar kvnloo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.