Giter Club home page Giter Club logo

actix-casbin-auth's People

Contributors

0xethsign avatar gopherj avatar greenhandatsjtu avatar hackerchai avatar hsluoyz avatar muzhou233 avatar psiace avatar selflocking avatar siddheshkanawade avatar smart--petea avatar thespooler avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

actix-casbin-auth's Issues

considering add a customized configuration in CasbinService to config error mesage?

for now the middleware use original error page built in actix-web,like

Ok(req.into_response(HttpResponse::Forbidden().finish().into_body()));
Ok(req.into_response(HttpResponse::BadGateway().finish().into_body()));
Ok(req.into_response(HttpResponse::Unauthorized().finish().into_body()));

but for some cases, we wanna keep the error message having the same structured response like other error type.
so maybe add some fields in CasbinService to config the response of error payload?

small problems

  1. remove the following unwrap

    let enforcer: CachedEnforcer = CachedEnforcer::new(m, a).await.unwrap();

  2. change to sync function, async will has at least 100ns's overhead

    pub async fn get_enforcer(&mut self) -> Arc<RwLock<CachedEnforcer>> {

  3. change to sync function

    pub async fn set_enforcer(e: Arc<RwLock<CachedEnforcer>>) -> Self {

no default features for actix-web

If/when the actix-web dependency is updated to v3, the dependency in Cargo.toml should ideally be:

- actix-web = "3.0.2"
+ actix-web = { version = "3.0.2", default-features = false }

error: could not compile `casbin`; the name `...` is defined multiple times

Hello,

I'm having trouble simply adding this crate to my project. The cfg conditional featured-based use statements do not seem to be taken into account. Here are the errors:

error[E0252]: the name `IoError` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:20:10
   |
13 |     io::{BufReader, Error as IoError, ErrorKind},
   |                     ---------------- previous import of the type `IoError` here
...
20 |     io::{Error as IoError, ErrorKind},
   |          ^^^^^^^^^^^^^^^^--
   |          |
   |          `IoError` reimported here
   |          help: remove unnecessary import
   |
   = note: `IoError` must be defined only once in the type namespace of this module

error[E0252]: the name `ErrorKind` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:20:28
   |
13 |     io::{BufReader, Error as IoError, ErrorKind},
   |                                       --------- previous import of the type `ErrorKind` here
...
20 |     io::{Error as IoError, ErrorKind},
   |                            ^^^^^^^^^ `ErrorKind` reimported here
   |
   = note: `ErrorKind` must be defined only once in the type namespace of this module

error[E0252]: the name `Path` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:21:5
   |
14 |     path::Path,
   |     ---------- previous import of the type `Path` here
...
21 |     path::Path,
   |     ^^^^^^^^^^ `Path` reimported here
   |
   = note: `Path` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
21 |     path::Path as OtherPath,
   |     ^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `File` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:25:5
   |
11 |     fs::File,
   |     -------- previous import of the type `File` here
...
25 |     fs::File,
   |     ^^^^^^^^ `File` reimported here
   |
   = note: `File` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
25 |     fs::File as OtherFile,
   |     ^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `BufReader` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/adapter/file_adapter.rs:26:42
   |
13 |     io::{BufReader, Error as IoError, ErrorKind},
   |          --------- previous import of the type `BufReader` here
...
26 |     io::{AsyncBufReadExt, AsyncWriteExt, BufReader},
   |                                          ^^^^^^^^^ `BufReader` reimported here
   |
   = note: `BufReader` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
26 |     io::{AsyncBufReadExt, AsyncWriteExt, BufReader as OtherBufReader},
   |                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `Cursor` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:13:11
   |
6  |     io::{BufReader, Cursor, Error as IoError, ErrorKind},
   |                     ------ previous import of the type `Cursor` here
...
13 | use std::{io::Cursor, path::Path};
   |           ^^^^^^^^^^ `Cursor` reimported here
   |
   = note: `Cursor` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
13 | use std::{io::Cursor as OtherCursor, path::Path};
   |           ^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `Path` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:13:23
   |
10 | use async_std::{fs::File, path::Path};
   |                           ---------- previous import of the type `Path` here
...
13 | use std::{io::Cursor, path::Path};
   |                       ^^^^^^^^^^ `Path` reimported here
   |
   = note: `Path` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
13 | use std::{io::Cursor, path::Path as OtherPath};
   |                       ^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `BufReader` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:16:36
   |
6  |     io::{BufReader, Cursor, Error as IoError, ErrorKind},
   |          --------- previous import of the type `BufReader` here
...
16 |     AsyncBufReadExt, AsyncReadExt, BufReader, Error as IoError, ErrorKind,
   |                                    ^^^^^^^^^ `BufReader` reimported here
   |
   = note: `BufReader` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
16 |     AsyncBufReadExt, AsyncReadExt, BufReader as OtherBufReader, Error as IoError, ErrorKind,
   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `IoError` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:16:47
   |
6  |     io::{BufReader, Cursor, Error as IoError, ErrorKind},
   |                             ---------------- previous import of the type `IoError` here
...
16 |     AsyncBufReadExt, AsyncReadExt, BufReader, Error as IoError, ErrorKind,
   |                                               ^^^^^^^^^^^^^^^^--
   |                                               |
   |                                               `IoError` reimported here
   |                                               help: remove unnecessary import
   |
   = note: `IoError` must be defined only once in the type namespace of this module

error[E0252]: the name `ErrorKind` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:16:65
   |
6  |     io::{BufReader, Cursor, Error as IoError, ErrorKind},
   |                                               --------- previous import of the type `ErrorKind` here
...
16 |     AsyncBufReadExt, AsyncReadExt, BufReader, Error as IoError, ErrorKind,
   |                                                                 ^^^^^^^^^-
   |                                                                 |
   |                                                                 `ErrorKind` reimported here
   |                                                                 help: remove unnecessary import
   |
   = note: `ErrorKind` must be defined only once in the type namespace of this module

error[E0252]: the name `File` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/config.rs:20:5
   |
10 | use async_std::{fs::File, path::Path};
   |                 -------- previous import of the type `File` here
...
20 | use tokio::fs::File;
   |     ^^^^^^^^^^^^^^^ `File` reimported here
   |
   = note: `File` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
20 | use tokio::fs::File as OtherFile;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0252]: the name `Path` is defined multiple times
  --> /home/arnaud/.cargo/registry/src/github.com-1ecc6299db9ec823/casbin-2.0.5/src/model/default_model.rs:19:5
   |
16 | use async_std::path::Path;
   |     --------------------- previous import of the type `Path` here
...
19 | use std::path::Path;
   |     ^^^^^^^^^^^^^^^ `Path` reimported here
   |
   = note: `Path` must be defined only once in the type namespace of this module
help: you can use `as` to change the binding name of the import
   |
19 | use std::path::Path as OtherPath;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 12 previous errors

These errors appear whether or not I add the features = ["runtime-tokio"] to my Cargo.toml. I'm working with rustc 1.49.0 (e1884a8e3 2020-12-29) and here is the list of dependencies from my Cargo.toml:

[dependencies]
actix-casbin-auth = { version = "0.4.4", features = ["runtime-tokio"] }
actix-files = "0.5.0"
actix-redis = "0.9.1"
actix-session = "0.4.0"
actix-web = { version = "3", default-features = false }
chrono = { version = "0.4.19", features = ["serde"]}
diesel = { version = "^1.4.4", features = ["postgres","r2d2","chrono"] }
diesel-adapter = { version = "0.8.3", features = ["postgres"] }
diesel-derive-enum = { version = "1.1.0", features = ["postgres"] }
dotenv = "0.15"
env_logger = "0.7"
failure = "0.1.8"
futures = "0.3.8"
lazy_static = "1.4.0"
lettre = "0.10.0-alpha.4"
log = "0.4.13"
regex = "1.4.3"
sailfish = "0.3.0"
sailfish-macros = "0.3.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sodiumoxide = "0.2.6"
strum_macros = "0.20.1"
uuid = { version = "0.8", features = ["serde", "v4"] }
walkdir = "2.3.1"

Any help would be appreciated.

Update dependencies on crates.io

actix-casbin-auth uses tokio 1.5.0, but the webpage on crates.io shows 0.2. -
Screenshot from 2021-05-05 07-12-18
Also few other dependencies like actix-rt also need to updated. Can this be manually done?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.