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
Merged
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
464c0d2
Add OpenID credential storage in stable structures and anchor managem…
sea-snake Jan 22, 2025
7db91b5
- OpenID credentials in stable structures.
sea-snake Jan 22, 2025
7e749e7
🤖 cargo-fmt auto-update
github-actions[bot] Jan 22, 2025
1a92adb
🤖 npm run generate auto-update
github-actions[bot] Jan 22, 2025
cca4497
Fix error in archive operation compat
sea-snake Jan 22, 2025
eaf5646
Fix error in anchor tests
sea-snake Jan 22, 2025
db90889
Add OpenID credentials to did.
sea-snake Jan 22, 2025
b3534cb
🤖 npm run generate auto-update
github-actions[bot] Jan 22, 2025
98e3455
Add OpenID credentials operations to archive did.
sea-snake Jan 22, 2025
279a73a
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 22, 2025
28e4640
Make OpenID credential in StableAnchor not optional.
sea-snake Jan 22, 2025
04117db
Make OpenID credentials in IdentityAnchorInfo optional so it's backwa…
sea-snake Jan 22, 2025
072252c
🤖 cargo-fmt auto-update
github-actions[bot] Jan 22, 2025
80d94ac
Make OpenID credentials in IdentityAnchorInfo optional so it's backwa…
sea-snake Jan 22, 2025
3042122
🤖 npm run generate auto-update
github-actions[bot] Jan 22, 2025
a555694
Fix principal from seed in tests
sea-snake Jan 22, 2025
bed886e
🤖 cargo-fmt auto-update
github-actions[bot] Jan 22, 2025
114d254
Changes based on feedback and added tests for new `Anchor` methods.
sea-snake Jan 23, 2025
2a6827b
🤖 cargo-fmt auto-update
github-actions[bot] Jan 23, 2025
4639e4e
Fix serde name for archive operation.
sea-snake Jan 23, 2025
5a7e8ef
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 23, 2025
aa1f722
Wrap tuple with struct since stable-structures doesn't directly suppo…
sea-snake Jan 23, 2025
0049fbc
🤖 cargo-fmt auto-update
github-actions[bot] Jan 23, 2025
5c47f82
Update based on feedback.
sea-snake Jan 23, 2025
3c78479
Update based on feedback.
sea-snake Jan 23, 2025
810af38
🤖 cargo-fmt auto-update
github-actions[bot] Jan 23, 2025
7c82534
Update based on feedback.
sea-snake Jan 23, 2025
e27c0ab
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 23, 2025
91a5432
🤖 cargo-fmt auto-update
github-actions[bot] Jan 23, 2025
73a061c
Update based on feedback.
sea-snake Jan 23, 2025
6280d3b
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 23, 2025
bb5b426
Update based on feedback.
sea-snake Jan 23, 2025
5e458d3
Update based on feedback.
sea-snake Jan 23, 2025
94026e7
Update based on feedback.
sea-snake Jan 23, 2025
41be074
Make lookup map many-to-many
sea-snake Jan 27, 2025
5157a1c
Make lookup map many-to-many
sea-snake Jan 27, 2025
34a8b8f
🤖 cargo-fmt auto-update
github-actions[bot] Jan 27, 2025
2234e72
🤖 npm run generate auto-update
github-actions[bot] Jan 27, 2025
9f061b7
Make lookup map many-to-many
sea-snake Jan 27, 2025
cfe4ffd
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 27, 2025
efac984
Implement canister methods and link to frontend to add and remove Ope…
sea-snake Jan 23, 2025
81874c3
Implement canister methods and link to frontend to add and remove Ope…
sea-snake Jan 23, 2025
4799a0e
WIP
sea-snake Jan 24, 2025
e1eb9af
WIP
sea-snake Jan 24, 2025
4257fad
Undo changes
sea-snake Jan 27, 2025
51c573b
Undo changes
sea-snake Jan 27, 2025
985939d
Add check to make sure OpenID credential is only added to a single an…
sea-snake Jan 27, 2025
0a74291
WIP
sea-snake Jan 24, 2025
18bb775
WIP
sea-snake Jan 24, 2025
0631fe2
Undo changes
sea-snake Jan 27, 2025
7f90e07
Undo changes
sea-snake Jan 27, 2025
770168a
🤖 cargo-fmt auto-update
github-actions[bot] Jan 27, 2025
f045a05
Fix import
sea-snake Jan 27, 2025
bfa4f0c
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 27, 2025
f7614a0
Add InternalCanisterError to error enums similar to v2 api.
sea-snake Jan 27, 2025
e6aec3e
Fix did file.
sea-snake Jan 27, 2025
8bfe986
🤖 npm run generate auto-update
github-actions[bot] Jan 27, 2025
37340fb
Remove frontend env variable and use backend config instead.
sea-snake Jan 28, 2025
08e0bb5
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 28, 2025
6c27565
Merge branch 'main' into sea-snake/openid-google-add-remove-from-anchor
sea-snake Jan 28, 2025
2268e5d
Remove `#[allow(unused)]` from methods that are now used.
sea-snake Jan 28, 2025
223447f
Update translation labels based on feedback.
sea-snake Jan 28, 2025
abd4a04
Add TODO comment.
sea-snake Jan 28, 2025
0a1a7d7
Add `should_register_openid_credential_only_for_a_single_anchor` test.
sea-snake Jan 28, 2025
69a7ac7
🤖 cargo-fmt auto-update
github-actions[bot] Jan 28, 2025
1b47942
Add `should_register_openid_credential_only_for_a_single_anchor` test.
sea-snake Jan 28, 2025
eb20b55
Merge remote-tracking branch 'origin/sea-snake/openid-google-add-remo…
sea-snake Jan 28, 2025
fcbef18
Move imports into test itself.
sea-snake Jan 28, 2025
0da1a61
Fix test
sea-snake Jan 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.

"shrink": false
},
"test_app": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"private": true,
"license": "SEE LICENSE IN LICENSE.md",
"scripts": {
"dev": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 II_OPENID_GOOGLE_CLIENT_ID=\"45431994619-cbbfgtn7o0pp0dpfcg2l66bc4rcg7qbu.apps.googleusercontent.com\" vite",
"host": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 II_OPENID_GOOGLE_CLIENT_ID=\"45431994619-cbbfgtn7o0pp0dpfcg2l66bc4rcg7qbu.apps.googleusercontent.com\" vite --host",
"dev": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 vite",
"host": "II_FETCH_ROOT_KEY=1 II_DUMMY_CAPTCHA=1 vite --host",
"showcase": "astro dev --root ./src/showcase",
"build": "tsc --noEmit && vite build",
"check": "tsc --project ./tsconfig.all.json --noEmit",
Expand Down
6 changes: 6 additions & 0 deletions src/archive/archive.did
sea-snake marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ type Operation = variant {
// Only the top level keys are archived for privacy reasons.
metadata_keys: vec text;
};
add_openid_credential: record {
iss: text;
};
remove_openid_credential: record {
iss: text;
};
};

type Entry = record {
Expand Down
14 changes: 13 additions & 1 deletion src/canister_tests/src/api/archive.rs
sea-snake marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ pub mod compat {
},
#[serde(rename = "remove_device")]
RemoveDevice { device: PublicKey },
#[serde(rename = "add_openid_credential")]
AddOpenIdCredential { iss: String },
#[serde(rename = "remove_openid_credential")]
RemoveOpenIdCredential { iss: String },
}

impl From<Operation> for CompatOperation {
Expand All @@ -98,7 +102,15 @@ pub mod compat {
new_device,
},
Operation::RemoveDevice { device } => CompatOperation::RemoveDevice { device },
Operation::IdentityMetadataReplace { .. } => panic!("not available in compat type"),
Operation::AddOpenIdCredential { iss } => {
CompatOperation::AddOpenIdCredential { iss }
}
Operation::RemoveOpenIdCredential { iss } => {
CompatOperation::RemoveOpenIdCredential { iss }
}
Operation::IdentityMetadataReplace { .. } => {
panic!("not available in compat type")
}
}
}
}
Expand Down
36 changes: 36 additions & 0 deletions src/frontend/generated/internet_identity_idl.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,23 @@ export const idlFactory = ({ IDL }) => {
'purpose' : Purpose,
'credential_id' : IDL.Opt(CredentialId),
});
const Aud = IDL.Text;
const Iss = IDL.Text;
const Sub = IDL.Text;
const OpenIdCredential = IDL.Record({
'aud' : Aud,
'iss' : Iss,
'sub' : Sub,
'metadata' : MetadataMapV2,
'last_usage_timestamp' : Timestamp,
});
const DeviceRegistrationInfo = IDL.Record({
'tentative_device' : IDL.Opt(DeviceData),
'expiration' : Timestamp,
});
const IdentityAnchorInfo = IDL.Record({
'devices' : IDL.Vec(DeviceWithUsage),
'openid_credentials' : IDL.Opt(IDL.Vec(OpenIdCredential)),
'device_registration' : IDL.Opt(DeviceRegistrationInfo),
});
const FrontendHostname = IDL.Text;
Expand Down Expand Up @@ -286,6 +297,7 @@ export const idlFactory = ({ IDL }) => {
'authn_methods' : IDL.Vec(AuthnMethodData),
'metadata' : MetadataMapV2,
'authn_method_registration' : IDL.Opt(AuthnMethodRegistrationInfo),
'openid_credentials' : IDL.Opt(IDL.Vec(OpenIdCredential)),
});
const IdentityInfoError = IDL.Variant({
'InternalCanisterError' : IDL.Text,
Expand Down Expand Up @@ -313,6 +325,20 @@ export const idlFactory = ({ IDL }) => {
'AlreadyInProgress' : IDL.Null,
'RateLimitExceeded' : IDL.Null,
});
const JWT = IDL.Text;
const Salt = IDL.Vec(IDL.Nat8);
const OpenIdCredentialAddError = IDL.Variant({
'OpenIdCredentialAlreadyRegistered' : IDL.Null,
'InternalCanisterError' : IDL.Text,
'Unauthorized' : IDL.Principal,
'JwtVerificationFailed' : IDL.Null,
});
const OpenIdCredentialKey = IDL.Tuple(Iss, Sub);
const OpenIdCredentialRemoveError = IDL.Variant({
'InternalCanisterError' : IDL.Text,
'OpenIdCredentialNotFound' : IDL.Null,
'Unauthorized' : IDL.Principal,
});
const UserKey = PublicKey;
const PrepareIdAliasRequest = IDL.Record({
'issuer' : FrontendHostname,
Expand Down Expand Up @@ -506,6 +532,16 @@ export const idlFactory = ({ IDL }) => {
),
'init_salt' : IDL.Func([], [], []),
'lookup' : IDL.Func([UserNumber], [IDL.Vec(DeviceData)], ['query']),
'openid_credential_add' : IDL.Func(
[IdentityNumber, JWT, Salt],
[IDL.Variant({ 'Ok' : IDL.Null, 'Err' : OpenIdCredentialAddError })],
[],
),
'openid_credential_remove' : IDL.Func(
[IdentityNumber, OpenIdCredentialKey],
[IDL.Variant({ 'Ok' : IDL.Null, 'Err' : OpenIdCredentialRemoveError })],
[],
),
'prepare_delegation' : IDL.Func(
[UserNumber, FrontendHostname, SessionKey, IDL.Opt(IDL.Nat64)],
[UserKey, Timestamp],
Expand Down
34 changes: 34 additions & 0 deletions src/frontend/generated/internet_identity_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ArchiveInfo {
'archive_config' : [] | [ArchiveConfig],
'archive_canister' : [] | [Principal],
}
export type Aud = string;
export type AuthnMethod = { 'PubKey' : PublicKeyAuthn } |
{ 'WebAuthn' : WebAuthn };
export type AuthnMethodAddError = { 'InvalidMetadata' : string };
Expand Down Expand Up @@ -175,6 +176,7 @@ export type IdRegStartError = { 'InvalidCaller' : null } |
{ 'RateLimitExceeded' : null };
export interface IdentityAnchorInfo {
'devices' : Array<DeviceWithUsage>,
'openid_credentials' : [] | [Array<OpenIdCredential>],
'device_registration' : [] | [DeviceRegistrationInfo],
}
export interface IdentityAuthnInfo {
Expand All @@ -185,6 +187,7 @@ export interface IdentityInfo {
'authn_methods' : Array<AuthnMethodData>,
'metadata' : MetadataMapV2,
'authn_method_registration' : [] | [AuthnMethodRegistrationInfo],
'openid_credentials' : [] | [Array<OpenIdCredential>],
}
export type IdentityInfoError = { 'InternalCanisterError' : string } |
{ 'Unauthorized' : Principal };
Expand Down Expand Up @@ -216,6 +219,8 @@ export interface InternetIdentityStats {
'canister_creation_cycles_cost' : bigint,
'event_aggregations' : Array<[string, Array<[string, bigint]>]>,
}
export type Iss = string;
export type JWT = string;
export type KeyType = { 'platform' : null } |
{ 'seed_phrase' : null } |
{ 'cross_platform' : null } |
Expand All @@ -238,6 +243,23 @@ export type MetadataMapV2 = Array<
]
>;
export interface OpenIdConfig { 'client_id' : string }
export interface OpenIdCredential {
'aud' : Aud,
'iss' : Iss,
'sub' : Sub,
'metadata' : MetadataMapV2,
'last_usage_timestamp' : Timestamp,
}
export type OpenIdCredentialAddError = {
'OpenIdCredentialAlreadyRegistered' : null
} |
{ 'InternalCanisterError' : string } |
{ 'Unauthorized' : Principal } |
{ 'JwtVerificationFailed' : null };
export type OpenIdCredentialKey = [Iss, Sub];
export type OpenIdCredentialRemoveError = { 'InternalCanisterError' : string } |
{ 'OpenIdCredentialNotFound' : null } |
{ 'Unauthorized' : Principal };
export type PrepareIdAliasError = { 'InternalCanisterError' : string } |
{ 'Unauthorized' : Principal };
export interface PrepareIdAliasRequest {
Expand Down Expand Up @@ -265,6 +287,7 @@ export type RegistrationFlowNextStep = {
'CheckCaptcha' : { 'captcha_png_base64' : string }
} |
{ 'Finish' : null };
export type Salt = Uint8Array | number[];
export type SessionKey = PublicKey;
export interface SignedDelegation {
'signature' : Uint8Array | number[],
Expand All @@ -282,6 +305,7 @@ export interface StreamingCallbackHttpResponse {
export type StreamingStrategy = {
'Callback' : { 'token' : Token, 'callback' : [Principal, string] }
};
export type Sub = string;
export type Timestamp = bigint;
export type Token = {};
export type UserKey = PublicKey;
Expand Down Expand Up @@ -404,6 +428,16 @@ export interface _SERVICE {
>,
'init_salt' : ActorMethod<[], undefined>,
'lookup' : ActorMethod<[UserNumber], Array<DeviceData>>,
'openid_credential_add' : ActorMethod<
[IdentityNumber, JWT, Salt],
{ 'Ok' : null } |
{ 'Err' : OpenIdCredentialAddError }
>,
'openid_credential_remove' : ActorMethod<
[IdentityNumber, OpenIdCredentialKey],
{ 'Ok' : null } |
{ 'Err' : OpenIdCredentialRemoveError }
>,
'prepare_delegation' : ActorMethod<
[UserNumber, FrontendHostname, SessionKey, [] | [bigint]],
[UserKey, Timestamp]
Expand Down
2 changes: 0 additions & 2 deletions src/frontend/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,3 @@ export const VERSION = import.meta.env.II_VERSION ?? "";
export const FETCH_ROOT_KEY = import.meta.env.II_FETCH_ROOT_KEY === "1";
export const DUMMY_AUTH = import.meta.env.II_DUMMY_AUTH === "1";
export const DUMMY_CAPTCHA = import.meta.env.II_DUMMY_CAPTCHA === "1";
export const II_OPENID_GOOGLE_CLIENT_ID = import.meta.env
.II_OPENID_GOOGLE_CLIENT_ID;
Loading
Loading