LeapChain / Website

MIT License
2 stars 4 forks source link

Implement User Authentication #13

Open hussu010 opened 2 years ago

hussu010 commented 2 years ago

Body of the request:

{
accountNumber": "c22f224dac22c6d02e94936f8ac256736555dcf270649f090b201a1bede9c5c8"
}

Response:

{
    "_id": "6277bf9459056edfe3a657ce",
    "accountNumber": "c22f224dac22c6d02e94936f8ac256736555dcf270649f090b201a1bede9c5c8",
    "nonce": 768051,
    "createdAt": "2022-05-08T13:03:16.222Z",
    "updatedAt": "2022-05-08T13:03:16.222Z",
    "__v": 0
}

PS: We are not using the JWT yet.

jamessspanggg commented 2 years ago

Are we missing some fields according to https://docs.google.com/document/d/1lOmcPgQFz6w-4JzLIYC6Tytw0_xedlpnBtdBZN6-Bqw/edit?

Some other follow up questions:

Once we have the nonce, ask the user to sign the message Signing my leapchain nonce: NONCE.

cc @hussu010 @mrbusysky

mrbusysky commented 2 years ago

Via keysign, also the backend should be verifying the signature, not the front end. @jamessspanggg the front end only handles the handshake method, and the post/get to backend. Plus the other stuff like storing data and so on in the local storage.

hussu010 commented 2 years ago

Are we missing some fields according to https://docs.google.com/document/d/1lOmcPgQFz6w-4JzLIYC6Tytw0_xedlpnBtdBZN6-Bqw/edit?

We decided to have the API independent of anything else and later connect the discord bot to API if necessary.

POST to /api/v1/users: this is to create the user account right? perhaps /api/v1/users/create might be a more suitable endpoint?

Sure I'll update the naming in the next release.

How are we performing the signing? is it via the https://thenewboston-developers.github.io/thenewboston-js/account.html#creating-signatures here? Also just to clarify, the signature is basically the account number signed with the nonce?

Exactly. Here we will be using the Keysign for the signature. If we were using the library it'd be:

const account = new Account();
account.createSignature("Signing my leapchain nonce: 234323");

Let me know if anything is unclear. cc: @mrbusysky @jamessspanggg

mrbusysky commented 2 years ago

WIP Prototype: https://github.com/LeapChain/Website/pull/18

mrbusysky commented 2 years ago

This is semi done. But it will need some cleanup