Page MenuHomePhabricator

[Identity] Add new types to handle tokens
ClosedPublic

Authored by varun on May 6 2022, 7:15 AM.
Tags
None
Referenced Files
F3113835: D3945.id12580.diff
Thu, Oct 31, 7:32 PM
F3113788: D3945.id12353.diff
Thu, Oct 31, 7:17 PM
Unknown Object (File)
Sun, Oct 13, 10:19 PM
Unknown Object (File)
Sun, Oct 13, 7:54 PM
Unknown Object (File)
Sun, Oct 13, 7:54 PM
Unknown Object (File)
Sun, Oct 13, 7:54 PM
Unknown Object (File)
Sun, Oct 13, 7:54 PM
Unknown Object (File)
Sun, Oct 13, 7:54 PM

Details

Summary

Our DatabaseClient will fetch user tokens from DynamoDB. We need a struct to store the data pertaining to a token.

We use the chrono crate to handle date/time

Test Plan

cargo build

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.May 6 2022, 7:15 AM
Harbormaster failed remote builds in B8856: Diff 12352!
varun requested review of this revision.May 6 2022, 7:23 AM

Split new types out into new token module

karol requested changes to this revision.EditedMay 9 2022, 2:51 AM

Why you don't put [services] prefix in your revisions' names for the identity service? I thought we had a convention that we put a prefix depending on the "module" we work on. So, for instance, [web], [server], [native]. [services] Is at the same level, [identity] is deeper one level. Is there a particular reason you do not do this here? Has this rule changed?

services/identity/src/token.rs
9–12 ↗(On Diff #12374)

What is the reason to use Option here? Why token is not optional and the rest of the fields are?

This revision now requires changes to proceed.May 9 2022, 2:51 AM
In D3945#110907, @karol-bisztyga wrote:

Why you don't put [services] prefix in your revisions' names for the identity service? I thought we had a convention that we put a prefix depending on the "module" we work on. So, for instance, [web], [server], [native]. [services] Is at the same level, [identity] is deeper one level. Is there a particular reason you do not do this here? Has this rule changed?

I have this pattern but I've actually never pushed it as a rule. The other day @jonringer-comm asked me if he should prefix his commit titles with [nix], so this is coming up in multiple places. Open to creating a rule for this but curious for other perspectives

In D3945#110907, @karol-bisztyga wrote:

Why you don't put [services] prefix in your revisions' names for the identity service? I thought we had a convention that we put a prefix depending on the "module" we work on. So, for instance, [web], [server], [native]. [services] Is at the same level, [identity] is deeper one level. Is there a particular reason you do not do this here? Has this rule changed?

I have this pattern but I've actually never pushed it as a rule. The other day @jonringer-comm asked me if he should prefix his commit titles with [nix], so this is coming up in multiple places. Open to creating a rule for this but curious for other perspectives

I see. For me, personally, it would be handier because I set my herald rule to detect any revisions with [services] in their names. If you decide to user other naming then fine but I think it will be better for everybody to use one, consistent pattern.

As a side note, maybe we could use tags?

That is a really good point about Herald rules. @benschac was asking on ENG-1055 about whether we should come up with a new Herald rule, since we're no longer recommending subscribing to all diffs... this idea makes sense to me.

i'll use [services][identity] going forward. are herald rules case sensitive?

services/identity/src/token.rs
9–12 ↗(On Diff #12374)

We use this struct to hold data returned from DynamoDB, so we need to handle incomplete data. I think token should actually be wrapped in an Option too... will fix

Rename Token to AccessToken to be more precise, make token field optional (to handle incomplete data in DynamoDB)

Accepting to preempt somebody adding me due to dependency change

back to you

services/identity/src/token.rs
9–12 ↗(On Diff #12374)

Sorry, but I don't really understand.

  1. This seems to be inconsistent with https://phabricator.ashoat.com/D3573?vs=on&id=11131:
  2. where's userID?
  3. why do you use just auth_type? I don't see pakePasswordCiphertext/walletAddress.
  4. What's the primary key here?
This revision now requires changes to proceed.May 16 2022, 1:00 AM
varun added inline comments.
services/identity/src/token.rs
9–12 ↗(On Diff #12374)
  1. I was passing userID and deviceID to functions as separate args in addition to the Token struct, but perhaps that's confusing. I can include all of it in the Token struct.
  1. https://phabricator.ashoat.com/D3573?vs=on&id=11902#toc in a later revision than the one you linked I realized we didn't actually need to store that stuff in the token table
  1. primary key is the userID (partition key) + deviceID (sort key)

add userID and deviceID to AccessToken struct

karol added inline comments.
services/identity/src/token.rs
9–12 ↗(On Diff #12374)

Thanks, I think having args more explicit in the struct is more readable.

This revision is now accepted and ready to land.May 24 2022, 12:21 PM
This revision was automatically updated to reflect the committed changes.