Page MenuHomePhabricator

[identity] GenerateNonce RPC
ClosedPublic

Authored by varun on Feb 22 2023, 11:45 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 10, 11:48 PM
Unknown Object (File)
Fri, May 10, 11:48 PM
Unknown Object (File)
Fri, May 10, 11:48 PM
Unknown Object (File)
Fri, May 10, 11:48 PM
Unknown Object (File)
Apr 18 2024, 10:28 PM
Unknown Object (File)
Apr 17 2024, 3:59 AM
Unknown Object (File)
Apr 17 2024, 3:59 AM
Unknown Object (File)
Apr 17 2024, 3:58 AM
Subscribers

Details

Summary

This RPC generates an alphanumeric nonce, persists it with the creation time, and then returns the nonce to the caller.

I chose 17 for the length of the nonce to stay consistent with the TypeScript SIWE library util. There is a siwe-rs implementation, but it returns a string of length 11... I created an issue in the siwe-rs repo so hopefully they'll make this consistent in the future: https://github.com/spruceid/siwe-rs/issues/46

Depends on D6836

Test Plan

created a test table in dynamodb and a new client method in the rust-node-addon, called generate_nonce, successfully received a nonce string. checked the ddb table to make sure it was persisted with creation timestamp.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

just suggestions, but overall looks fine

services/identity/src/database.rs
447–456 ↗(On Diff #22941)

Might be nice to create a facade for creating the the DDB structures, but don't feel strongly about it. Just a lot of white space from cargo fmt

services/identity/src/service.rs
267–273 ↗(On Diff #22941)

not sure if you like this style more

This revision is now accepted and ready to land.Feb 22 2023, 3:59 PM
This revision was automatically updated to reflect the committed changes.
services/identity/src/database.rs
447–456 ↗(On Diff #22941)

yeah the whitespace is annoying but in this case i want the reader to know immediately that we're inserting a HashMap

services/identity/src/service.rs
267–273 ↗(On Diff #22941)

i think i prefer the original, feels a little more clear