greymass / anchor-link

Persistent, fast and secure signature provider for EOSIO chains built on top of EOSIO Signing Requests (EEP-7)
Other
53 stars 22 forks source link

Can't Find A Way To Authorize User On My Server #22

Closed BartolomeoItaliano closed 3 years ago

BartolomeoItaliano commented 3 years ago

I am trying to authorize user who logins through Anchor Wallet on my page server, but I cannot find a way to do so.

In Scatter Wallet I used "getArbitrarySignature" method, which returns string signed with private key, I send this encrypted string to my server and there I decrypt it with public key, compare with original string and I know I am dealing with the user.

How I can achieve users server authorization in Anchor Wallet? I found in login payload "sig" property which is some encrpyted string but, I cannot find what is the original string it refers to.

Please help.

jnordberg commented 3 years ago

What you do is call either .login() (or just identify() if it's a pure backend/login-only application) then submit the "identity proof" to the server for validation.

const {proof} = link.login('test')
sendToServer(JSON.stringify(proof))

Look here for an example on how to verify the proofs: https://github.com/greymass/idproofer

If you're not using node.js on your server or don't want to spin up your own instance of idproofer feel free to use the one Greymass hosts over at https://eosio.greymass.com/prove

BartolomeoItaliano commented 3 years ago

Short comment for JS inheritage:

This worked for me: import * as superagent from "superagent"; const response = await superagent.post("https://eosio.greymass.com/prove").send(JSON.stringify({proof:anchorWalletProof}));