-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Add http
& https
asset sources (clean commit history)
#17889
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
base: main
Are you sure you want to change the base?
Conversation
Just a quick note, ring is now unmaintained for the foreseeable future. |
Adding MPL as an allowed license seems like it would have complications for distributing game binaries, no? That said, I'm not clear what new dependency here actually requires it. Both ureq and webpki-roots support MIT and Apache 2.0 from looking at their repos. |
ring is maintained again, now by the rustls team |
blocked on finding where the MPL license comes from and removing it |
waiting on a new release of webpki-root with this commit: rustls/webpki-roots@90c48f3#diff-8aec0a2c31031e00524df726f854726660ec8289dcddfa70005000fc21b00511 |
As of right now, ring is not actually included in this PR, it was replaced by aws-lc-rs. Now that ring has removed the OpenSSL parts of the license, I think we can remove aws-lc-rs, remove OpenSSL from deny.toml and use the ureq's default ring dependency again. This would be especially nice because aws-lc-rs requires installing CMake on Windows. |
I agree, more iteration is requried but this pr is already substantial. How about we create a follow-up issue for discussion on whats needed to complete |
I've spoken with @cart about this, and we'd like to move forward with this as a solution for example assets (in addition to thinking it's broadly useful). We just need a second approval now to get this merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similar to how the file asset source exposes only a directory and not the whole filesystem, I think an https source should only allow access to a domain and not the whole internet
You added a new feature but didn't update the readme. Please run |
* Rename and split http_source feature to http and https * Enable http sources when using processed asset mode * Fix ureq/rustls feature gate (it was only working by accident because ureq with full features is part of the dev dependencies) * Disable gzip and json ureq features * Misc. rewording of a couple docs * Setup HttpSourcePlugin as part of DefaultPlugins to allow for future configuration (there is currently none)
Http source fixes
I am quite biased towards allowing more than 1 origin because I’m currently making a bevy game where not all my assets are hosted over the same server. Otherwise I see the upside of being able to neatly switch out the asset server host name but there’s also the downside that we would lose the neatness of the asset path being the URL. Do you think a config option to specify allowed host names would be a good alternative? |
I have given this some more thought and I'm starting to turn around to the idea. I don't think a config option for allowed host names would be that useful since its quite easy to parse the url and do any checking you want manually before you load an asset. I didn't know this until now but file assets can be loaded from absolute paths but they will be rejected unless unapproved_path_mode is set accordingly. We could probably do the same for web assets by having the same unapproved_path_mode option to allow access to the entire internet if required. The main problem I see is that relative paths already default to the file system and afaik there is no common syntax to define a relative http URL so we would have to come up with our own syntax which doesn't clash with absolute http URLs which I don't think would be very intuitive. Another issue is that unlike the assets folder, there is no sensible default origin. If we want to force people to pick an origin (which would be good practice), we wouldn't be able to make the Plugin Default and that would make it annoying to construct (in the future when it has many config options). |
I think this is more a feature than an issue. Having to opt in to http on a specific domain is a better way to use it in my opinion. If the number of config options becomes too large, we can either rely on a default implementation for most options, or a builder pattern |
Objective
This is a duplicate of #16366 because I made a mess of the commit history. See that pr for more context and discussion.
bevy_web_asset
, allowing assets loaded viahttp
#16307http
&https
asset sources #16366Solution
http
&https
asset sourcesCDLA-Permissive-2.0
indeny.toml
Testing
cargo run --example http_source --features="http_source"
Showcase
Bevy now supports assets loaded via url!
Add the
http_source
feature to load assets served over the web, with support for both native and wasm targets. On native targets thehttp_source_cache
feature will use a basic caching mechanism to avoid repeated network requests.Further Work
fetch
, in the future we'll have many reasons to be making requests.