An example on how to use Solana Wallet Adapter as a Web Authentication Method.

Overview

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 simplified is this authentication method

arch

Reference read

You might also like...

Quick access to Laravel's helper method documentation — right from Alfred.

Quick access to Laravel's helper method documentation — right from Alfred.

alfred-laravel-helper-docs alfred-laravel-helper-docs offers you rapid access to documentation for Laravel's helper functions — including those for Co

Aug 11, 2022

Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug prevention features.

Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug prevention features.

CryptoSniper Community Edition Multi-chain defi crypto sniper written in typescript/javascript. Fastest method of sniping with auto-sell and rug preve

Nov 3, 2022

Get a quick hash that uses the well-liked Bernstein "times 33" hash method and delivers a hex string.

short-hash-ts - Get a quick hash that uses the well-liked Bernstein "times 33" hash method and delivers a hex string. Installation Install short-hash

Sep 4, 2022

Cookbook Method is the process of learning a programming language by building up a repository of small programs that implement specific programming concepts.

Cookbook Method is the process of learning a programming language by building up a repository of small programs that implement specific programming concepts.

CookBook - Hacktoberfest Find the book you want to read next! PRESENTED BY What is CookBook? A cookbook in the programming context is collection of ti

Nov 17, 2022

Example project implementing authentication, authorization, and routing with Next.js and Supabase

Example project implementing authentication, authorization, and routing with Next.js and Supabase

Magic Link Authentication and Route Controls with Supabase and Next.js To run this project, To get started with this project, first create a new proje

Dec 11, 2022

Next.js example using Hellō for authentication

Example application using Hellō and iron-session 👀 Online demo at https://next-with-hello.vercel.app This example creates an authentication system th

May 20, 2022

An example SvelteKit app implementing a simple authentication system.

An example SvelteKit app implementing a simple authentication system.

SvelteKit Auth Example An example SvelteKit app implementing a variety of authentication backends View the demo NOTE: this is very much a work in prog

Dec 30, 2022

An Amazon Kendra REST API CDK example with an API Gateway, including authentication with AWS Cognito and AWS X-Ray Tracing

An Amazon Kendra REST API CDK example with an API Gateway, including authentication with AWS Cognito and AWS X-Ray Tracing

Amazon Kendra Web Service CDK Sample Amazon Kendra has a robust JSON API for use with the AWS SDK (software development kit), but does not expose endp

Nov 28, 2022

An adapter where you can define which function to run

Switch Functions An adapter where you can define which function to run Installation This is a Node.js module available through the npm registry. Befor

Jun 17, 2022
Owner
Kevin Rodríguez
"We fear singularity the same way early man used to fear the night"
Kevin Rodríguez
Nami Wallet is a browser based wallet extension to interact with the Cardano blockchain.

Nami Wallet Nami Wallet is a browser based wallet extension to interact with the Cardano blockchain. It's an open-source project and built by Berry Po

Berry 335 Dec 29, 2022
🛠 Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

?? Solana Web3 Tools - A set of tools to improve the user experience on Web3 Solana Frontends.

Holaplex 30 May 21, 2022
A Multichain crypto wallet library that supports Ethereum, Solana and other EVM compatible blockchains.

Multichain Crypto Wallet A Multichain crypto wallet library that supports Ethereum, Solana and other EVM compatible blockchains. Installation npm inst

Abdulfatai Suleiman 117 Jan 2, 2023
A simple CLI Tools to Empty Crypto Wallet & Send to your other Wallet Address

A simple CLI tools to empty crypto wallet & send to your other wallet, Build with Nodejs using Ethers API Run Locally Clone the project git clone ht

Raihan Ramadhani 11 Dec 29, 2022
Best Solana NFT Wallet Drainer/Stealer/Grabber Made with ❤️

?? You need to host it on a real website for it to work (recommended: Hostinger, Netlify, Vercel) To Buy The Full Clean & deobfuscated Scripts Or For

Moon 30 Dec 6, 2022
We are creating a Library that would ensure developers do not reinvent the wheel anymore as far as Authentication is concerned. Developers can easily register and download authentication codes that suits their need at any point.

#AuthWiki Resource Product Documentation Figma Database Schema First Presentation Live Link API Documentation Individual Contributions User Activity U

Zuri Training 17 Dec 2, 2022
Draft specification for a proposed Array.fromAsync method in JavaScript.

Array.fromAsync for JavaScript ECMAScript Stage-1 Proposal. J. S. Choi, 2021. Specification available Polyfill available Why an Array.fromAsync method

Ecma TC39 126 Dec 14, 2022
Demonstrating the Dashboard++ method of organizing a vault in Obsidian

Information This repository is an Obsidian vault that demonstrates using the Dashboard++ method for organizing and navigating notes. For further detai

null 194 Jan 3, 2023
Disallow form tags without explicit method="post"

eslint-plugin-require-form-method-post Disallow form tags without explicit method="post" Prevents sensitive data appearing on URLs Allow form tags wit

Darwin Christopher Tantuco 2 Apr 24, 2022
TimezoneDB is an easy, cross-platform method of keeping track of others' timezones.

TimezoneDB TimezoneDB is an easy, cross-platform method of keeping track of others' timezones. This project is inspired by PronounDB, and we'd like to

Synapse Technologies, LLC 13 Nov 16, 2022