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

icx-proxy should only consult query string and referrer when run locally #165

Open
nomeata opened this issue May 6, 2021 · 0 comments
Open
Assignees

Comments

@nomeata
Copy link
Contributor

nomeata commented May 6, 2021

I see that icx-proxy has inherited the logic of picking canister ids from hostname, query string, or referer, in that order from the dfx bootstrap command:

fn resolve_canister_id(
request: &Request<Body>,
dns_canister_config: &DnsCanisterConfig,
) -> Option<Principal> {
// Look for subdomains if there's a host header.
if let Some(host_header) = request.headers().get("Host") {
if let Ok(host) = host_header.to_str() {
if let Some(canister_id) = resolve_canister_id_from_hostname(host, dns_canister_config)
{
return Some(canister_id);
}
}
}
// Look into the URI.
if let Some(canister_id) = resolve_canister_id_from_uri(request.uri()) {
return Some(canister_id);
}
// Look into the request by header.
if let Some(referer_header) = request.headers().get("referer") {
if let Ok(referer) = referer_header.to_str() {
if let Ok(referer_uri) = hyper::Uri::from_str(referer) {
if let Some(canister_id) = resolve_canister_id_from_uri(&referer_uri) {
return Some(canister_id);
}
}
}
}
None
}

But support for query and referer is only needed for local development, right? It might be confusing if this logic is used “in production”.

I suggest to make looking into the query string and referrer optional, and only enable it when icx-proxy is run as part of dfx start.

@ericswanson-dfinity ericswanson-dfinity self-assigned this May 6, 2021
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

No branches or pull requests

2 participants