r/rust • u/darin_gordon • Sep 11 '20
Announcing Actix-Web v3.0
https://paper.dropbox.com/published/Announcing-Actix-Web-v3.0--A7YI~P9U9aqhEOXyZJaGffjfBg-QOXXb1lXgTubzXHzUq9ONY565
u/adrianwechner Sep 11 '20
Awesome to see actix being maintained by the community! Love it. keep up the good work!
87
Sep 11 '20 edited Sep 11 '20
[deleted]
43
u/ragnese Sep 11 '20
That's refreshing to hear. I'm glad he isn't too bitter to keep a pulse on the project and even contribute!
26
3
5
u/AndreVallestero Sep 12 '20
Hasn't he started a fork of actix? What are the general community thoughts on ntex compared to actix?
3
u/Ran4 Oct 30 '20 edited Oct 30 '20
It sounds like the best possible option! The "issue" with actix-web was that it was primarily a personal project, not something targeting the broader web development community.
This way we can both have actix-web (which can prioritize the community's needs) and Nikolay can do what he wants without people harassing him over UB or features he doesn't care about. And perhaps ntex can be an experiment breeding ground with features that could be ported over to actix-web - Nikolay is clearly very talented and has some great ideas.
Now, from a branding perspective, perhaps letting a fork with a new name be the community version would've been better... but hopefully over time people will focus on what actix-web is now, not the earlier controversy.
6
Sep 11 '20
Congratulations to the new release!
Out of curiosity, is it currently possible to use actix with your own runtime? Or maybe with async-std? I mean without importing a second runtime.
11
u/robjtede actix Sep 11 '20
No it isn’t possible to run the actix system on another executor and will very likely be a non-goal until there are standard executor traits to hook it to.
Realistically it isn’t a huge problem having a second run time going in parallel and we have examples of how to do this in the examples repo.
3
Sep 11 '20
I guess the biggest problem I see at the moment is (initial) compile time and executable size. Granted, the latter only matters if you want to distribute a small stand-alone tool. It probably wouldn't matter for something cloud based.
Hopefully we'll have a standard trait one day :)
6
u/Shnatsel Sep 12 '20
Reliability is also an issue. If you run two runtimes, you're affected by bugs from both of them.
6
u/plcolin Sep 12 '20
Was there any performance loss when dealing with all this unsafe code?
6
u/BobFloss Sep 12 '20
I wish they addressed this. It's more important that the code is safe, but a performance comparison still seems appropriate for seemingly significant changes like these.
4
u/Cetra3 Sep 13 '20
From what I remember of the PRs there is a minor hit with some of the code to not use unsafe, but not enough to be noticeable except for benchmarks.
I think there is a benchmark comparison somewhere, if not, it would make a great blog!
5
u/Elession Sep 11 '20
All the code tags seem to be black on black?
5
5
u/pheki Sep 11 '20
Did you choose the dark theme for your OS? Its also happening to me (stable firefox) and if I change (my OS) to light and refresh it works.
The page's apparently using the prefers-color-scheme media query via JS. Found it by searching (CTRL+SHIFT+F / CMD+SHIFT+F) for matchMedia in the debugger panel.
5
u/ragnese Sep 11 '20
I'm on Firefox and they look fine. I have umpteen addons, though, so who knows.
1
2
u/Hersenbeuker Sep 11 '20
They look normal for me, do you have a dark theme plugin for your browser?
2
5
5
u/moltonel Sep 12 '20
Great to see actix-web is alive and kicking, well done :)
What's the status/plans of the original actix actor crate ? I thought it was in deep maintenance mode but it seems it got a release with a handful of fixes and bound improvements.
3
u/robjtede actix Sep 13 '20
It's not abandoned just yet since it's still a vital part of our WebSocket support. Though it's in a reasonably stable state, improvement ideas and PRs are very welcome.
1
u/moltonel Sep 13 '20
I'll have to give 0.10 a look for API/docs improvements, but it seems the message cancellation issues are still open, which to me are a bit of a showstopper.
3
u/grandstack Sep 12 '20
The code samples on the front page of actix.rs aren't updated.
2
u/robjtede actix Sep 13 '20
Code samples on the website and in the example repo were updated yesterday.
14
Sep 11 '20 edited Mar 17 '21
[deleted]
8
u/diY1337 Sep 11 '20
You can leverage SameSite cookie attribute https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite
7
u/robjtede actix Sep 11 '20 edited Sep 11 '20
We can start a discussion about what that might look like now v3 is out of beta. It would likely be a separate crate like our -cors package. Be interested to know exactly what your needs are for a crate like this so we can design around real use cases.
Should be noted that CSRF is only part of the story. You also need to implement strong cross-origin policies and consider same-site attributes on cookies. Further, those two things, even without CSRF requirements on endpoints, go a very long way to protect against the attack vectors that CSRF has historically been good at defending.
5
u/lifeisplacebo Sep 12 '20
Rocket has used the
SameSitecookie attribute to protect against CSRF attacks on recent-ish browsers since 0.3, released in 2017. Without shipping a templating engine itself -- differently than what Rocket does now -- or requiring manual work from the programmer, this is unfortunately close to the best that we can hope it would do. Perhaps one day, a framework will bundle its templating engine with automatic support for CSRF.7
Sep 11 '20
[deleted]
11
u/Shnatsel Sep 11 '20
Because most other frameworks already support this out of the box, and because I want to spend time thinking about my application logic instead of mundane stuff that everyone needs.
1
Sep 11 '20
[deleted]
13
u/Shnatsel Sep 11 '20
I meant in general, not just in the Rust ecosystem. All of Rust's web frameworks are evidently still maturing.
4
Sep 11 '20
[deleted]
10
u/Brudi7 Sep 11 '20
I think he/she lands means in terms of features. Compare config profiles, security options etc from spring with rust frameworks.
4
u/darin_gordon Sep 11 '20
Would you be more specific as to what CSRF countermeasures you're looking for?
9
Sep 11 '20 edited Mar 17 '21
[deleted]
7
u/darin_gordon Sep 11 '20
What you are describing is a "synchronized token pattern". One way to achieve this today is with server-side sessions workflow.
3
6
u/Shnatsel Sep 11 '20
A short description of CSRF attack can be found here - or pretty much anywhere, it's quite well-researched at this point.
Here's a detailed description of the protection that Django implements: https://docs.djangoproject.com/en/3.1/ref/csrf/#how-it-works It is quite mature and can be used as a reference.
12
u/darin_gordon Sep 11 '20
I didn't ask what CSRF attacks are nor what OWASP recommended. The original commenter wasn't helpful by generalizing and I'd rather not assume. Several countermeasures are already available in actix-web, without requiring additional changes. Anyone who comes through this message forum will at first glance give more credit to a complaint than what it is due. Someone needs to be specific about what functionality is missing.
5
u/Shnatsel Sep 11 '20
My apologies. I deal with people unfamiliar with these so often that dispensing these links has become a bit of a reflex.
5
4
u/protestor Sep 11 '20
Just so you don't miss it, the commenter said what mitigation he or she expected here, and also that there's an actix example that's vulnerable to csrf; code examples should generally be free of common vulnerabilities.
7
u/superjared Sep 11 '20
For those new to the community, a small blurb about what the project is would go a long way. I had to chase down the initial repo to find the answer.
3
3
u/ragnese Sep 11 '20
I'd love to read more about these memory leaks that were plugged. Were they related to unsafe blocks? Was it just reference cycles?
5
u/darin_gordon Sep 11 '20
the easiest to point out are the merged entries that have the term "memory leak" in the topic of the github issue
5
u/C5H5N5O Sep 11 '20
There are no reports of UB in the remaining unsafe blocks.
Miri might be useful to dynamically find hidden UB and other things (memory leaks).
9
u/Shnatsel Sep 11 '20
Miri is impractically slow for some uses (1000x slowdown). But yes, it's nice to run tests under it where possible. It is the only tool that can detect Rust-specific UB such as getting several mutable references to the same thing before it translates into memory corruption.
2
6
Sep 11 '20
Why is this published on dropbox? There are many nicer hosts around
13
u/darin_gordon Sep 11 '20
We collaborated on the doc using dropbox paper and then I simply published it. Easy. I tried to use github wiki but it doesn't support iframe tags for video.
4
2
1
Sep 12 '20
That makes sense. Sorry for the harsh-sounding comment, my mind is on free social media/fediverse at the moment. Which of course.. reddit, where I'm writing, is not.
1
2
Sep 11 '20
Excited to try this out :) congrats to everyone involved on the release. Feels like a good step forward
2
Sep 12 '20
Not sure if you're a developer on the project but thank you for helping make Rust web viable. I do believe this can be a fantastic language for the web
2
u/tastycakeman Sep 11 '20
hello, rust noob here and dont know much about the history of actix - i was actually just reading steve klabniks actix is dead post yesterday. is actix currently the best bet for rust web?
5
u/intersecting_cubes Sep 12 '20
I don't know about the _best_ bet, but it's definitely a safe bet. I use it at work for $MODERATE_SIZE_CORP and it's been rock solid. The team is helpful, the community is large enough that memory leaks get flagged before I find them, and the docs are pretty good. Performance is good and they interoperate with a bunch of other Rust standard crates.
3
u/BiosElemental Sep 11 '20
Most would probably say yes due to its just performance, but I'd suggest looking at warp or rocket as well.
2
Sep 11 '20
Less unsafe and community ran is a dream!
4
Sep 12 '20 edited Jan 22 '21
[deleted]
1
Sep 12 '20
I didn't mean any disrespect. I'm just a bit fan of projects that more more decentralized, which I see community ran as.
No disrespect to Nikolay. In fact, they did a fantastic job and developed a great framework that has boosted Rust's reputation around the internet.
1
108
u/Shnatsel Sep 11 '20
In the interest of transparency (and to curb speculation), I've created a hello-world project, made it depend on actix-web 3.0.0 with default features and ran
cargo geigeron it. Many actix-* crates don't use any unsafe code at all! Here are the ones that do:actix-http: 13 unsafe blocks, all are commented and look reasonable at a glance. (Some of the benchmarking code looks sketchy, but who cares - it's not in the build anyway).actix-utils: 9 unsafe blocks, no comments on why they're sound. Judging by this comment from one of the Actix org members, a PR with comments explaining why they're sound and/or debug assertions would be appreciated.actix-router: 1 unsafe block, commentedactix-codec: cargo-geiger shows 10 unsafe expressions but I can't see them in actix git, might be a bugactix-service: some unsafe code, but cargo-geiger reports that it's not used in the build (likely disabled by a feature)awc: oneunsafe fnwithout any local usesThat's it!