DDtKey / protect-endpoints

Authorization extension for popular web-frameworks to protect your endpoints
Apache License 2.0
202 stars 14 forks source link

Fails to build against actix_web 4.0.0-beta.14 #23

Closed tl8roy closed 2 years ago

tl8roy commented 2 years ago

After trying to update to beta.14, I get the following error. The second one looks like a quick fix. Not so sure about the first one.

error[E0599]: no method named `extensions` found for reference `&RequestHead` in the current scope
  --> /home/.cargo/git/checkouts/actix-web-grants-fc366f5a984b4e1f/f2f9964/src/guards.rs:44:14
   |
44 |             .extensions()
   |              ^^^^^^^^^^ method not found in `&RequestHead`

error[E0599]: no method named `extensions` found for struct `HttpRequest` in the current scope
  --> /home/.cargo/git/checkouts/actix-web-grants-fc366f5a984b4e1f/f2f9964/src/permissions/mod.rs:97:17
   |
97 |             req.extensions()
   |                 ^^^^^^^^^^ method not found in `HttpRequest`
   |
  ::: /home/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-http-3.0.0-beta.15/src/http_message.rs:29:8
   |
29 |     fn extensions(&self) -> Ref<'_, Extensions>;
   |        ---------- the method is available for `HttpRequest` here
   |
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
16 | use actix_web::HttpMessage;

I have reverted to an old Cargo.lock file which I'll stay with for now.

DDtKey commented 2 years ago

@tl8roy thanks for the info! Beta versions of actix-web 4 are sometimes backwards incompatible. This will definitely be fixed for actix-web-grants

After the release of the version, I will additionally report here.

DDtKey commented 2 years ago

So, first error caused by actix-web changes 2487. In fact, it upsets me. At the moment, we have only two options: 1) Give up support of Guard way protection 2) Work-around approach: use headers instead of extensions. But it seems strange and less optimal, however it works fine (I've tested). It could be moved to the optional feature of actix-web-grants, so that it doesn't affect users who do not use this feature.

Current actix-web documentation of Guard is incorrect. I hope find any comments from core-team after that we will take our direction 🤔

DDtKey commented 2 years ago

It looks like the first issue will be fixed in the next versions of actix-web (https://github.com/actix/actix-web/pull/2552) 🚀

DDtKey commented 2 years ago

actix-web-grants 3.0.0-beta.5 has just been released! 🎉 It works with current actix-web: 4.0.0-beta.18