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 allowed origins to make webui work again #1544

Merged
merged 2 commits into from
Aug 2, 2015
Merged

Conversation

whyrusleeping
Copy link
Member

I'm not really sure what these changes mean, All I know is that the webui now works and I can add files through that interface again.

cc @mappum @diasdavid @jbenet and anyone else who can tell me if what i've done here is right.

License: MIT
Signed-off-by: Jeromy [email protected]

@jbenet jbenet added the status/in-progress In progress label Jul 30, 2015
@whyrusleeping
Copy link
Member Author

I would also love to have some tests to somehow make sure the webui works against each ipfs commit so we dont accidentaly break things as we move along.

"http://localhost",
"https://localhost",
"127.0.0.1:5001",
"localhost:5001",
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably get the API port from the config rather than hardcoding port 5001.

Copy link
Member

Choose a reason for hiding this comment

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

👍 to @mappum's comment. should try to grab it from config.

i think this is the key part: adding the API port, not removing the protocol. this should work then:

var localhostOrigins = []string{
 "http://127.0.0.1:<api-port>", 
 "https://127.0.0.1:<api-port>",
 "http://localhost:<api-port>",   
 "https://localhost:<api-port>",    
 }

Copy link
Member Author

Choose a reason for hiding this comment

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

but the protocol isnt part of the url host

@mappum
Copy link
Contributor

mappum commented Jul 30, 2015

Other than my inline comment, this looks good. It's important to restrict access only to the API server, instead of all localhost origins/referers, otherwise attacks can still come from pages served over the local gateway (http://localhost:8080/ipfs/EVIL_PAGE). (This PR does that, the previous change did not).

for _, o := range cfg.CORSOpts.AllowedOrigins {
if o == "*" { // ok! you asked for it!
return true
}

if o == origin { // allowed explicitly
Copy link
Member

Choose a reason for hiding this comment

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

no, i think the protocol matters to CORS, one should be able to set CORS on https only 👎

@jbenet jbenet force-pushed the fix/allowed-origins branch 3 times, most recently from 9d06375 to 1d94d6f Compare August 2, 2015 06:07
ServeOptions take the node and muxer, they should get the listener
too as sometimes they need to operate on the listener address.

License: MIT
Signed-off-by: Juan Batiz-Benet <[email protected]>
need to do it this way to avoid VERY confusing situations where
the user would change the API port (to another port, or maybe even
to :0). this way things dont break on the user, and by default,
users only need to change the API address and things should still
"just work"

License: MIT
Signed-off-by: Juan Batiz-Benet <[email protected]>
jbenet added a commit that referenced this pull request Aug 2, 2015
fix allowed origins to make webui work again
@jbenet jbenet merged commit b19dd47 into master Aug 2, 2015
@jbenet jbenet removed the status/in-progress In progress label Aug 2, 2015
@jbenet jbenet deleted the fix/allowed-origins branch August 2, 2015 06:30
@jbenet
Copy link
Member

jbenet commented Aug 2, 2015

thanks for helping fix this @whyrusleeping 👍

@whyrusleeping
Copy link
Member Author

@jbenet thanks for actually fixing it 😄

@krl
Copy link
Contributor

krl commented Aug 3, 2015

@whyrusleeping the api has a test suite that should probably be run on go-ipfs changes as well, i made the tests use browserify/phantomjs as well

@whyrusleeping
Copy link
Member Author

@krl that would be pretty sweet to have. How would we hook up those tests to the go-ipfs CI?

@jbenet jbenet mentioned this pull request Aug 3, 2015
35 tasks
hacdias pushed a commit to ipfs/boxo that referenced this pull request Jan 27, 2023
fix allowed origins to make webui work again

This commit was moved from ipfs/kubo@b19dd47
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.

4 participants