This plugin allows users to create their account using their web3 provider (ex. metamask).
- Install
users-permissions
plugin. - Copy
webthree-auth
folder inside thesrc/plugins
directory of a Strapi project. - Extends
user
schema ofusers-permissions
plugin with to string fields :token
andaddress
- Using Admin panel : in
Content-Type Builder
, add 2 string fields in theUser
collection type
, name ittoken
andaddress
. Token field should be private. - Using plugin extension file (copy schema from original
users-permissions
file if needed) :
// src/extensions/users-permissions/content-types/user/schema.json { // ... "attributes": { // ... "token": { "type": "string", "private": true }, "address": { "type": "string" } // ... }, // ... }
- Using Admin panel : in
http://127.0.0.1:1337/webthree-auth/token/:address
Address is the 0x address provided by the web3 client (metamask)
Request :
http://127.0.0.1:1337/webthree-auth/token/0x123456789123456789123456789123456789A06F
Result :
{
"token": "9ec1012a-53e6c5f9-b2b440a9-5d7ea75a"
}
http://127.0.0.1:1337/webthree-auth/authenticate/:address/:signature
Address is the 0x address provided by the web3 client (metamask)
Signature is a string obtained when user sign a message with his web3 client (metamask) Message should contain signature and default message is
'Your authentication token : ' + token
Request :
http://127.0.0.1:1337/webthree-auth/authenticate/0x123456789123456789123456789123456789A06F/0xa1fa12355b1bb0094c2b1234d77e4aa684b6332e712349edf1ea1b99878d8f682e27a4e89ea67cd8db1fc6ac32ae11125ecffbd8925dc546343cfe0542c9a43a1c