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

Add and remove OpenID credentials from anchor #2810

Merged
merged 69 commits into from
Jan 28, 2025

Conversation

sea-snake
Copy link
Contributor

@sea-snake sea-snake commented Jan 22, 2025

Changes

  • OpenID credentials in stable structures.
  • Lookup anchor number by OpenID credential in stable structures.
  • Anchor management methods to add/remove OpenID credentials.
  • Anchor management method to lookup anchor with OpenID credential.
  • Canister methods to add/remove OpenID credentials.
  • Replaced frontend mock OpenID implementation with above canister methods.
  • Use canister config endpoint to get Google client id for FedCM interaction.

Tests

Added additional anchor tests:

  • should_add_openid_credential
  • should_remove_openid_credential
  • should_update_openid_credential

Added additional storage test:

  • should_write_and_update_openid_credential_lookup

🟡 Some screens were changed

Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

A few comments. Looking good. I'd like to leave until tomorrow to think about the implications of adding the StableAnchor to the memory.

My first impression, is that it makes sense. Let's discuss again tomorrow.

src/internet_identity/src/openid.rs Outdated Show resolved Hide resolved
src/internet_identity/src/openid.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage.rs Show resolved Hide resolved
src/internet_identity/src/storage/anchor.rs Show resolved Hide resolved
src/internet_identity/src/storage/anchor.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage/stable_anchor.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage/anchor.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage/anchor.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage/stable_anchor.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage.rs Outdated Show resolved Hide resolved
src/internet_identity/src/openid.rs Show resolved Hide resolved
@lmuntaner
Copy link
Collaborator

@sea-snake after sleeping over this new memory, I can't find a reason not to move forward. Looks good to me!

Let me know when the PR is ready for the final review.

@sea-snake sea-snake marked this pull request as ready for review January 23, 2025 14:38
@sea-snake sea-snake requested a review from lmuntaner January 23, 2025 14:47
src/internet_identity/src/anchor_management.rs Outdated Show resolved Hide resolved
pub fn update_openid_credential(
anchor: &mut Anchor,
openid_credential: OpenIdCredential,
) -> Result<(), AnchorError> {

Choose a reason for hiding this comment

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

There is probably a good reason and might be related to how it's going to be used later, but I just wanted to point out that the update here is seemingly inconsistent with add/remove in terms of return type, and also different from add/remove/update for devices.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's intentional, compared to updating a device, updating a credential doesn't result in any operation that needs to be stored in the archive canister. This is because a device its metadata can change after user action e.g. alias change while an OpenID credential will be updated on every JWT verification (to keep latest claims from OpenID provider stored).

Additionally, I intentionally only keep track of the issuer in operations for the archive canister, anything beyond that would likely impact a user's privacy. This data is enough to keep track of adoption of a given OpenId without knowing details beyond that.

src/internet_identity/src/storage/stable_anchor.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage.rs Show resolved Hide resolved
@sea-snake sea-snake requested a review from lmuntaner January 28, 2025 00:04
Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Collaborator

@lmuntaner lmuntaner left a comment

Choose a reason for hiding this comment

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

Thanks! I left a few comments.

This PR is too big for my taste, it's hard to keep track of all the implications. Please test it carefully before merging.

I'm requesting changes to prevent merging before the comments are addressed.

@@ -5,7 +5,7 @@
"candid": "src/internet_identity/internet_identity.did",
"wasm": "internet_identity.wasm.gz",
"build": "bash -c 'II_DEV_CSP=1 II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=${II_DUMMY_CAPTCHA:-1} scripts/build'",
"init_arg": "(opt record { captcha_config = opt record { max_unsolved_captchas= 50:nat64; captcha_trigger = variant {Static = variant {CaptchaDisabled}}}})",
"init_arg": "(opt record { captcha_config = opt record { max_unsolved_captchas= 50:nat64; captcha_trigger = variant {Static = variant {CaptchaDisabled}}}; openid_google = opt opt record { client_id = \"45431994619-cbbfgtn7o0pp0dpfcg2l66bc4rcg7qbu.apps.googleusercontent.com\" }})",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this our dev environment? Did you check with IT about the prod one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a dev environment I created, only works internally within DFINITY. This should be removed at a later point and replaced with instructions on creating a client id and configuring it with II.

Haven't gotten around to ask IT about the prod one yet, we'll need to also ask them to create others for our other environments.

src/frontend/src/flows/manage/index.ts Show resolved Hide resolved
src/frontend/src/utils/iiConnection.ts Show resolved Hide resolved
src/internet_identity/src/anchor_management.rs Outdated Show resolved Hide resolved
src/internet_identity/src/anchor_management.rs Outdated Show resolved Hide resolved
src/internet_identity/src/anchor_management.rs Outdated Show resolved Hide resolved
src/internet_identity/src/storage/anchor.rs Show resolved Hide resolved
@sea-snake sea-snake requested a review from lmuntaner January 28, 2025 12:24
@sea-snake sea-snake added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit 67f9c63 Jan 28, 2025
67 checks passed
@sea-snake sea-snake deleted the sea-snake/openid-google-add-remove-from-anchor branch January 28, 2025 14:27
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