Page MenuHomePhabricator

[Identity] DatabaseClient method to put tokens in DDB
ClosedPublic

Authored by varun on May 6 2022, 1:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, May 4, 12:37 AM
Unknown Object (File)
Thu, May 2, 10:00 PM
Unknown Object (File)
Thu, May 2, 4:43 PM
Unknown Object (File)
Wed, May 1, 10:29 PM
Unknown Object (File)
Tue, Apr 30, 6:35 PM
Unknown Object (File)
Tue, Apr 30, 1:36 AM
Unknown Object (File)
Sun, Apr 28, 4:06 PM
Unknown Object (File)
Sun, Apr 28, 12:13 AM

Details

Summary

This method, as explained in the diff title, lets us store user tokens in DynamoDB. Note that we convert the DateTime type to an RFC 3339 string. This seemed like the cleanest available option.

Depends on D3961

Test Plan

successfully put a token in DDB

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.May 6 2022, 1:36 PM
karol added inline comments.
services/identity/src/database.rs
242–243 ↗(On Diff #12387)

I know this comes from the db (right?) but shouldn't we add unsupported here?

This revision is now accepted and ready to land.May 9 2022, 4:51 AM

I'm not sure why this is in an "accepted" state. I hope it cannot be landed... After I accept, rust diffs should not be accepted, I know rust far too little to be decisive. Adding Jim as blocking.

This revision now requires review to proceed.May 9 2022, 4:53 AM
In D3962#110950, @karol-bisztyga wrote:

I'm not sure why this is in an "accepted" state. I hope it cannot be landed... After I accept, rust diffs should not be accepted, I know rust far too little to be decisive. Adding Jim as blocking.

When any reviewer accepted a diff and there are no blocking reviewers the state is accepted. If we want more people to accept before landing, we need to set them as blocking - just as you did.

Just a couple ways to make things more concise and/or readable. Feel free to ignore if you don't like it.

services/identity/src/database.rs
234 ↗(On Diff #12387)

nit: I'd write this as

let created_string = token.created
  .ok_or_else(|| {
    error!(...);
    Error::MissingAttribute
  })?;
249 ↗(On Diff #12387)

nit: I'd write this as

let valid_bool = token.valid
  .ok_or_else(|| {
    error!(...);
    Error::MissingAttribute
  })?;
308 ↗(On Diff #12387)

This can just be map_err(Error::RusotoPut) or even map_err(Into::into)

This revision is now accepted and ready to land.May 9 2022, 10:07 AM
services/identity/src/database.rs
234 ↗(On Diff #12387)

I'd have to write another line to convert the DateTime<Utc> to a String, right?

242–243 ↗(On Diff #12387)

this doesn't come from the db. auth_type is an enum in the Token struct with only two variants, so there's nothing else to handle in this match statement

249 ↗(On Diff #12387)

makes sense

308 ↗(On Diff #12387)

makes sense

@varun you may need to re-request review to get @jimpo's attention so it shows up on his queue. If that doesn't work feel free to ping him about your question