Skip to content

LG-6204/LG-6220: capture user pii in a signed JWT and pass to frontend#6282

Merged
solipet merged 7 commits intomainfrom
dprice-lg-6204-pass-user-bundle-token
May 5, 2022
Merged

LG-6204/LG-6220: capture user pii in a signed JWT and pass to frontend#6282
solipet merged 7 commits intomainfrom
dprice-lg-6204-pass-user-bundle-token

Conversation

@solipet
Copy link
Contributor

@solipet solipet commented Apr 29, 2022

Captures the current state of the user's pii (and a few other session state variables) and packs them in a JWT that is used to initialize the React app for the new IdV flow.

As we work our way back in the flow from the end, we will eventually be managing the user PII in the client, though we will be passing the JWT back and forth since it will contain the verified data and will be signed by the server.

The pii in the JWT is added to the initial values that are given to the React app.

@solipet solipet force-pushed the dprice-lg-6204-pass-user-bundle-token branch from b8e353a to f60f3d0 Compare April 29, 2022 21:06
@solipet solipet force-pushed the dprice-lg-6204-pass-user-bundle-token branch from f60f3d0 to 96d37d9 Compare May 3, 2022 17:54
@solipet solipet force-pushed the dprice-lg-6204-pass-user-bundle-token branch 2 times, most recently from c47f69e to 31c1a35 Compare May 4, 2022 21:33
@solipet solipet marked this pull request as ready for review May 4, 2022 23:12
@solipet solipet requested review from aduth, nprimak and peggles2 May 4, 2022 23:12
Comment on lines 37 to 38
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I seem to recall you mentioning we might not need this?

Suggested change
data[:issuer] = service_provider.issuer if service_provider

Copy link
Contributor Author

@solipet solipet May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup - I completely removed the SP from the tokenizer in 8a4cac1cb ee036db05 b3501a7f9

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Separately, we should start thinking about how to only include the user bundle and remove personalKey. That being said, we'll probably still need it as long as personal key is the only enabled step, if we ship it before others.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, eventually we won't even need the bundle - this is all temporary.

@solipet solipet force-pushed the dprice-lg-6204-pass-user-bundle-token branch from 8a4cac1 to ee036db Compare May 5, 2022 15:04
Copy link
Contributor

@aduth aduth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Confirmed the PII makes it into the flow:

image

Comment on lines 52 to 65
Copy link
Contributor

@aduth aduth May 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed in our working session, really tempting to pull in Lodash here:

Suggested change
const camelCase = (string: string) =>
string.replace(/[^a-z]([a-z])/gi, (_match, nextLetter) => nextLetter.toUpperCase());
const jwtData = JSON.parse(atob(initialValues.userBundleToken.split('.')[1]));
const pii = Object.fromEntries(
Object.entries(jwtData.pii).map(([key, value]) => [camelCase(key), value]),
);
import { mapKeys, camelCase } from 'lodash-es';
const jwtData = JSON.parse(atob(initialValues.userBundleToken.split('.')[1]));
const pii = mapKeys(jwtData.pii, camelCase);

@solipet solipet force-pushed the dprice-lg-6204-pass-user-bundle-token branch from ee036db to b3501a7 Compare May 5, 2022 16:04
@solipet solipet force-pushed the dprice-lg-6204-pass-user-bundle-token branch from b3501a7 to 32854ae Compare May 5, 2022 18:18
@solipet solipet merged commit 6f051ab into main May 5, 2022
@solipet solipet deleted the dprice-lg-6204-pass-user-bundle-token branch May 5, 2022 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants