Skip to content

Use Ethereum Node as auth engine

Ethereum node could be used as auth engine for Pheix CMS administration level.

Firstly it's handy from the point of auth. We can use node credentials as login-password pair, once the user is logged in to Geth node:

  1. we can get check the login details with list_wallets: https://web3py.readthedocs.io/en/latest/web3.geth.html?highlight=listwallets#web3.geth.personal.list_wallets;
  2. every fail attempt to store data related to session expiration (just handle unlock_account exception) we can support with login-password form;
  3. check session expiration with background ajax request - if expired fallback to login-password form;
Welcome to the Geth JavaScript console!

instance: Geth/pheix-authnode-msk-ru/v1.9.25-unstable-3ef52775-20201120/linux-amd64/go1.15.5
coinbase: 0xcdf4e0481e796afae76a9e4c537d4b895925b0cc
at block: 4128774 (Mon Jan 18 2021 22:44:40 GMT+0000 (UTC))
 modules: debug:1.0 eth:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0

> personal
{
  listAccounts: ["0xcdf4e0481e796afae76a9e4c537d4b895925b0cc"],
  listWallets: [{
      accounts: [{...}],
      status: "Locked",
      url: "keystore:///root/goerli-node/keystore/UTC--2020-07-20T13-58-30.446715534Z--cdf4e0481e796afae76a9e4c537d4b895925b0cc"
  }],
  deriveAccount: function(),
  ecRecover: function(),
  getListAccounts: function(callback),
  getListWallets: function(callback),
  importRawKey: function(),
  initializeWallet: function(),
  lockAccount: function(),
  newAccount: function(),
  openWallet: function(),
  sendTransaction: function(),
  sign: function(),
  signTransaction: function(),
  unlockAccount: function(),
  unpair: function()
}
> 

listWallets is set to undefined on Parity client:

Welcome to the Geth JavaScript console!

instance: Parity-Ethereum//v2.5.13-stable-253ff3f37-20191231/x86_64-linux-gnu/rustc1.42.0
coinbase: 0x00bd138abd70e2f00903268f3db08f2d25677c9e
at block: 0 (Thu Jan 01 1970 00:00:00 GMT+0000 (UTC))
 modules: debug:1.0 eth:1.0 net:1.0 parity:1.0 parity_accounts:1.0 parity_set:1.0 personal:1.0 rpc:1.0 traces:1.0 web3:1.0

> personal
{
  listAccounts: ["0x004ec07d2329997267ec62b4166639513386f32e", "0x00bd138abd70e2f00903268f3db08f2d25677c9e"],
  listWallets: undefined,

...

So, this feature will not work for non-Geth nodes.

Edited by Konstantin Narkhov