ddtkey/actix-web-grants

actix-web-grants

To check user access to specific services, you can use built-in proc-macro, PermissionGuard or manual

actix-web-grants

Extension for actix-web to validate user permissions.

To check user access to specific services, you can use built-in proc-macro, PermissionGuard or manual.

The library can also be integrated with third-party solutions (like actix-web-httpauth).

How to use

  1. Declare your own permission extractor

The easiest way is to declare a function with the following signature (trait is already implemented for such Fn):

  1. Add middleware to your application using the extractor defined in step 1

Steps 1 and 2 can be replaced by custom middleware or integration with another libraries. Take a look at an jwt-httpauth example

  1. Protect your endpoints in any convenient way from the examples below:

Example of proc-macro way protection

Example of ABAC-like protection and custom permission type

Here is an example using the type and secure attributes. But these are independent features.

secure allows you to include some checks in the macro based on function params.

type allows you to use a custom type for the roles and permissions (then the middleware needs to be configured). Take a look at an enum-role example

Example of Guard way protection

Example of custom fallback endpoint for `Scope` with `Guard`

Since Guard is intended only for routing, if the user doesn't have permissions, it returns a 404 HTTP code. But you can override the behavior like this:

When Guard lets you in the Scope (meaning you have "ROLE_ADMIN_ACCESS"), the redirect will be unreachable for you. Even if you will request /admin/some_undefined_page.

Note: regex is a Path variable containing passed link.

Example of manual way protection

You can find more examples in the git repository folder and documentation.

Supported actix-web versions

  • For actix-web-grants: 2.* supported version of actix-web is 3.*
  • For actix-web-grants: 3.* supported version of actix-web is 4.*
Versions

Find the latest versions by id

3.0.1 - Jun 01, 2022

What's Changed

New Contributors

Full Changelog: https://github.com/DDtKey/actix-web-grants/compare/3.0.0...3.0.1

3.0.0 - Apr 03, 2022

v3.0.0 - 22-04-03

Added

  • actix-web: 4.0.1 support 🚀 #30

3.0.0-beta.6 - Jan 08, 2022

v3.0.0-beta.6 - 2022-01-08

Added

  • Support custom types for permissions/roles #25
  • actix-web: 4.0.0-beta.19 support #27

2.3.0 - Jan 08, 2022

v2.3.0 - 2022-01-08

Supported version of actix-web is 3.*

Added

  • Support custom types for permissions/roles #25

3.0.0-beta.5 - Dec 30, 2021

v3.0.0-beta.5 - 2021-12-30

Added

  • actix-web: 4.0.0-beta.18 support #24

3.0.0-beta.4 - Nov 17, 2021

Supported version of actix-web is 4.0.0-beta.11

v3.0.0-beta.4 - 2021-11-17

Changed

  • Remove unused Config type #20

3.0.0-beta.3 - Oct 11, 2021

v3.0.0-beta.3 - 2021-10-11

Supported version of actix-web is 4.0.0-beta.9

Added

  • Allow extractor to receive mutable requests #17
  • How to use section to readme #18

2.2.0 - Oct 11, 2021

v2.2.0 - 2021-10-11

Supported version of actix-web is 3.*

Added

  • Allow extractor to receive mutable requests #17
  • How to use section to readme #18

Information - Updated Aug 01, 2022

Stars: 100
Forks: 10
Issues: 0
Actix

7.2K

Actix Rust Framework for web and wasm based applications

Rust's premier framework for handling large scale web applications across a wide varaitey of operating systems

Actix Rust Framework for web and wasm based applications

Rust/Actix Example

REST server using the Rust language to give you an idea of how it all works

Rust/Actix Example

Example using Rust Actix-web (web framework) with juniper (Graphql) with diesel (ORM)

Diesel's Getting Started guide using SQLite for Actix web

Example using Rust Actix-web (web framework) with juniper (Graphql) with diesel (ORM)

Example microservice in Rust and Actix

Beginners guide to using rust with a simple example

Example microservice in Rust and Actix

rust_actixweb_boilerplate

The Rust Actix_Web Boilerplate is a boilerplate for developers who want to get started with Actix_web's web applications faster

rust_actixweb_boilerplate

REST API with Rust using Actix-Web 2

GET /users ➡ returns all users

REST API with Rust using Actix-Web 2

REST API with Rust using Actix-Web 2

GET /users ➡ returns all users

REST API with Rust using Actix-Web 2

rust-actix-rest-api-boilerplate

A Rust RESTful API server with actix web and docker

rust-actix-rest-api-boilerplate

Rust actix json request example

Send a json request to actix, and parse it

Rust actix json request example

rust-actix-graphql-sqlx-postgresql

Using GraphQL with Rust and Apollo Federation

rust-actix-graphql-sqlx-postgresql

rust-actix-react-web-starter

A bare Rust web app that uses Diesel and License

rust-actix-react-web-starter

REST-API-with-Rust-and-Actix

This is a simple REST API developed using RUST Actix

REST-API-with-Rust-and-Actix
Facebook Instagram Twitter GitHub Dribbble
Privacy