Skip to content

Commit

Permalink
Add well-known asset for Related Origin Requests
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Dec 3, 2024
1 parent d9e8e2a commit 701c4bf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/asset_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ lazy_static! {
let mut map = HashMap::new();
map.insert(Path::new(".well-known/ic-domains").to_owned(), (ContentType::JSON, ContentEncoding::Identity));
map.insert(Path::new(".well-known/ii-alternative-origins").to_owned(), (ContentType::JSON, ContentEncoding::Identity));
map.insert(Path::new(".well-known/webauthn").to_owned(), (ContentType::JSON, ContentEncoding::Identity));
map
};
}
Expand Down Expand Up @@ -645,6 +646,11 @@ fn should_return_correct_extension() {
ContentType::JSON,
ContentEncoding::Identity,
),
(
".well-known/webauthn",
ContentType::JSON,
ContentEncoding::Identity,
),
(
".well-known/ii-alternative-origins",
ContentType::JSON,
Expand Down
10 changes: 10 additions & 0 deletions src/internet_identity/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ pub fn get_static_assets() -> Vec<Asset> {
encoding: ContentEncoding::Identity,
content_type: ContentType::OCTETSTREAM,
});

// Required to share passkeys with the different domains.
// See https://web.dev/articles/webauthn-related-origin-requests#step_2_set_up_your_well-knownwebauthn_json_file_in_site-1
// Maximum of 5 labels. If we want to support more, we'll need to set them in the configuration.
assets.push(Asset {
url_path: "/.well-known/webauthn".to_string(),
content: b"{\"origins\":[\"https://beta.identity.ic0.app\",\"https://beta.identity.internetcomputer.org\",\"https://identity.internetcomputer.org\",\"https://identity.ic0.app\",\"https://identity.icp0.io\"]}".to_vec(),
encoding: ContentEncoding::Identity,
content_type: ContentType::OCTETSTREAM,
});
assets
}

Expand Down
1 change: 1 addition & 0 deletions src/internet_identity/tests/integration/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ fn ii_canister_serves_http_assets() -> Result<(), CallError> {
("/", None),
("/index.js", Some("gzip")),
("/.well-known/ic-domains", None),
("/.well-known/webauthn", None),
];
let env = env();
let canister_id = install_ii_canister(&env, II_WASM.clone());
Expand Down

0 comments on commit 701c4bf

Please sign in to comment.