Skip to content

Commit 4bba927

Browse files
atergaCopilot
andauthored
chore: Avoid hard codeing /.well-known/ic-domains (#3638)
# Motivation The domains specified in /.well-known/ic-domains of the II canisters should not be hard coded but should instead depend on the canister config. # Changes Set /.well-known/ic-domains to all the domains from `related_origins`. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 5f7de94 commit 4bba927

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/internet_identity/src/assets.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,15 @@ pub fn get_static_assets(config: &InternetIdentityInit) -> Vec<Asset> {
9393
// See https://internetcomputer.org/docs/current/developer-docs/production/custom-domain/#custom-domains-on-the-boundary-nodes
9494
assets.push(Asset {
9595
url_path: "/.well-known/ic-domains".to_string(),
96-
content: b"identity.internetcomputer.org\nbeta.identity.ic0.app\nbeta.identity.internetcomputer.org\nid.ai\nbeta.id.ai\nwww.id.ai".to_vec(),
96+
content: config
97+
.related_origins
98+
.clone()
99+
.unwrap_or_default()
100+
.into_iter()
101+
.map(|origin| origin.replace("https://", ""))
102+
.collect::<Vec<_>>()
103+
.join("\n")
104+
.into_bytes(),
97105
encoding: ContentEncoding::Identity,
98106
content_type: ContentType::OCTETSTREAM,
99107
});

src/internet_identity_frontend/src/main.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,10 +322,17 @@ fn get_static_assets(config: &InternetIdentityFrontendArgs) -> Vec<AssetUtilAsse
322322
});
323323

324324
// Add .well-known/ic-domains for custom domain support
325-
let ic_domains_content = b"identity.internetcomputer.org\nbeta.identity.ic0.app\nbeta.identity.internetcomputer.org\nid.ai\nbeta.id.ai\nwww.id.ai".to_vec();
326325
assets.push(AssetUtilAsset {
327326
url_path: "/.well-known/ic-domains".to_string(),
328-
content: ic_domains_content,
327+
content: config
328+
.related_origins
329+
.clone()
330+
.unwrap_or_default()
331+
.into_iter()
332+
.map(|origin| origin.replace("https://", ""))
333+
.collect::<Vec<_>>()
334+
.join("\n")
335+
.into_bytes(),
329336
encoding: ContentEncoding::Identity,
330337
content_type: ContentType::OCTETSTREAM,
331338
});

0 commit comments

Comments
 (0)