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

Fix misleading guidance on disallowed host #2006

Merged
merged 1 commit into from
Nov 1, 2023

Conversation

itowlson
Copy link
Collaborator

@itowlson itowlson commented Nov 1, 2023

If you make a HTTP request to a disallowed host, Spin currently recommends that you add https://whatever:{80|443} (default port for your scheme) to your AOH. E.g.

// Rust
spin_sdk::http::send(Request::get("http://localhost:23234"))

// Message
To allow requests, add 'allowed_outbound_hosts = ["https://localhost:80"]' to the manifest component section.

This PR displays the original scheme of the request, and the custom port if one was used:

To allow requests, add 'allowed_outbound_hosts = ["http://localhost:23234"]' to the manifest component section.

Apologies for the lack of tests. The function is a bit monolithic at the moment; after release, we can look into factoring out more testable bits such as the validation/error routine.

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson requested review from lann, dicej and rylev November 1, 2023 00:34
@itowlson itowlson enabled auto-merge November 1, 2023 00:34
Comment on lines +511 to +518
let port = match port {
Some(port_str) => port_str.to_string(),
None => uri
.scheme()
.and_then(|s| (s == &Scheme::HTTP).then_some(80))
.unwrap_or(443)
.to_string(),
};
Copy link
Collaborator

@rylev rylev Nov 1, 2023

Choose a reason for hiding this comment

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

Nit:

Suggested change
let port = match port {
Some(port_str) => port_str.to_string(),
None => uri
.scheme()
.and_then(|s| (s == &Scheme::HTTP).then_some(80))
.unwrap_or(443)
.to_string(),
};
let port = port.unwrap_or_else(|| uri
.scheme()
.and_then(|s| (s == &Scheme::HTTP).then_some("80"))
.unwrap_or("443"))

@itowlson itowlson merged commit ee5b781 into spinframework:main Nov 1, 2023
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.

2 participants