Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UID2-3506 Add functionality on oncall page to list related keysets and rotate them #329

Merged
merged 23 commits into from
Aug 8, 2024

Conversation

cYKatherine
Copy link
Contributor

@cYKatherine cYKatherine commented Aug 5, 2024

UI looks below. It will highlight the reason why the keyset is related to the participant. Also tested the rotation works.

image

image

image

@cYKatherine cYKatherine self-assigned this Aug 5, 2024
@cYKatherine cYKatherine changed the title UID2-3506 Add backend change for listing related keysets UID2-3506 Add functionality on oncall page to list related keysets and rotate them Aug 5, 2024
@cYKatherine cYKatherine force-pushed the kcc-UID2-3506-list-keys-need-to-be-rotated branch 2 times, most recently from f84c010 to 76379a2 Compare August 5, 2024 12:54
@cYKatherine cYKatherine force-pushed the kcc-UID2-3506-list-keys-need-to-be-rotated branch from 76379a2 to 413f065 Compare August 5, 2024 12:54
@cYKatherine cYKatherine force-pushed the kcc-UID2-3506-list-keys-need-to-be-rotated branch from ef3020c to 837ddbb Compare August 5, 2024 13:30
@cYKatherine cYKatherine force-pushed the kcc-UID2-3506-list-keys-need-to-be-rotated branch from ab04e93 to d7515d8 Compare August 6, 2024 12:05
@cYKatherine cYKatherine force-pushed the kcc-UID2-3506-list-keys-need-to-be-rotated branch from d7515d8 to 9875b73 Compare August 6, 2024 12:06
const ja = JSON.parse(keysets);
var rotateKeysetsMessage = '';
ja.forEach((keyset) => {
var url = `/api/key/rotate_keyset_key?min_age_seconds=3600&keyset_id=${keyset.keyset_id}&force=true`;

Choose a reason for hiding this comment

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

I doublechecked the code, the min age seconds doesn't matter if we set force to true, maybe we can just set min_age_seconds=0 here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I tried setting min_age_seconds=0 but it will return with 404 as it needs a positive integer 😢 I can change it to 1 if that makes more sense 🤷‍♀️

Copy link
Contributor

Choose a reason for hiding this comment

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

should we make min_age_seconds=0 not return a 404 then and get rid of force?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lemme separate that to a new ticket as it's behaviour change 😢 and need some extra frontend work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vishalegbert-ttd
Copy link

Just want to confirm, it looks like the Rotate All Keys will also rotate master keys and site keys for ID_READER?

@cYKatherine
Copy link
Contributor Author

Just want to confirm, it looks like the Rotate All Keys will also rotate master keys and site keys for ID_READER?

Technically speaking this shouldn't happen. master keys and site keys (with site id -1 and -2) shouldn't have any allowed_sites or allowed_types. I checked our integ and prod environment and attached the screenshot.
image

// b. If this participant has a client key with ID_READER role, we want to rotate all the keysets where allowed_sites is set to null
// c. Keysets where allowed_sites include the leaked site
// d. Keysets belonging to the leaked site itself
if (containsAny(keyset.getValue().getAllowedTypes(), clientTypes) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw there is a method canClientAccessKey which is the source of truth.

Would be great if we could use that here, although might not be feasible. If we can't use it, still worth mentioning it here as a comment.

void RelatedKeysetSetsWithClientTypes(Vertx vertx, VertxTestContext testContext) {
fakeAuth(Role.MAINTAINER);

AdminKeyset adminKeyset1 = new AdminKeyset(3, 5, "test", Set.of(4,6,7), Instant.now().getEpochSecond(),true, true, new HashSet<>(Arrays.asList(ClientType.DSP, ClientType.PUBLISHER)));
Copy link
Contributor

Choose a reason for hiding this comment

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

might be worth checking out the test cases for canClientAccessKey

const ja = JSON.parse(keysets);
var rotateKeysetsMessage = '';
ja.forEach((keyset) => {
var url = `/api/key/rotate_keyset_key?min_age_seconds=3600&keyset_id=${keyset.keyset_id}&force=true`;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we make min_age_seconds=0 not return a 404 then and get rid of force?

@jon8787
Copy link
Contributor

jon8787 commented Aug 7, 2024

did we add some text / warning about what will happen when you click Rotate?

@cYKatherine
Copy link
Contributor Author

did we add some text / warning about what will happen when you click Rotate?

Done


<div class="col">
<a href="#" class="btn btn-primary" id="doRotateKeysets">Rotate Keysets</a>
<div>Note: Once rotated, the participant will need to get a new refresh key to be able to decrypt data.</div>
Copy link
Contributor

@jon8787 jon8787 Aug 8, 2024

Choose a reason for hiding this comment

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

Suggested wording:
"Normally, keys don't become active for 24 hours when rotated, which gives participants 24 hours before they need to call sdk.refresh().
However in this case, rotation will make the new keys active immediately. This means participants will not be able to decrypt newly created UID tokens until they have called sdk.refresh(). Note that we recommend calling sdk.refresh() once per hour".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

@cYKatherine cYKatherine merged commit 15f3771 into main Aug 8, 2024
4 checks passed
@cYKatherine cYKatherine deleted the kcc-UID2-3506-list-keys-need-to-be-rotated branch August 8, 2024 03:30
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