Skip to content

jamesyang124/ethereum-auth

Repository files navigation

Local Run

go run ./app.go

# generate swagger
go get github.com/swaggo/swag/cmd/swag
Swag init -g app.go

Test with ginkgo

cd handlers
# generate test suite for handlers directory
# package name is handlers_test
ginkgo boostrap
ginkgo generate health_check.go

# under that folder
# run test suite
ginkgo --v
# run only regexp matched "Metadata" in any described clause ex: Describe/It
ginkgo -v --focus=Metadata ./handlers
# run only regexp matched "without input payload" in any described clause ex: Describe/It
ginkgo -v --focus="without input payload" ./handlers

ginkgo -v ./handlers

Local Docker Compose Run

# rebuild docker image for fiber app
docker-compose build

docker-compose up

docker-compose down

Introduction

APIs:

# bump version when release
/version

/health

# get templating or other app info, ex sign-in templating
/api/ethereum-auth/v1/metadata

# generate and cache nonce on redis then respond to user
/api/ethereum-auth/v1/nonce

# verify signature and auth system account binding etc.
/api/ethereum-auth/v1/login

Reference

  1. https://npmdoc.github.io/node-npmdoc-web3/build/apidoc.html
  2. https://www.toptal.com/ethereum-smart-contract/time-locked-wallet-truffle-tutorial
  3. https://www.toptal.com/ethereum/one-click-login-flows-a-metamask-tutorial
  4. https://eth.wiki/json-rpc/API#eth_sign
  5. https://medium.com/@angellopozo/ethereum-signing-and-validating-13a2d7cb0ee3
  6. https://eips.ethereum.org/EIPS/eip-191
  7. https://javascript.hotexamples.com/examples/eth-lib.lib.hash/-/keccak256/javascript-keccak256-function-examples.html
  8. https://geth.ethereum.org/docs/clef/apis
  9. https://en.wikipedia.org/wiki/Elliptic_Curve_Digital_Signature_Algorithm
  10. https://goethereumbook.org/signature-verify/
  11. https://medium.com/mycrypto/the-magic-of-digital-signatures-on-ethereum-98fe184dc9c7

ecrecovery id

since testRPC other protocols will add 27, we need to minus it for Geth go-ethereum.

if protocol is Geth or Quorum => ecrecover id don't need to - 27

Releases

No releases published

Packages

No packages published