Skip to content

Instantly share code, notes, and snippets.

@SiddheshKanawade
Last active February 11, 2023 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SiddheshKanawade/b00617440bce177d2222eeab4e1d91fe to your computer and use it in GitHub Desktop.
Save SiddheshKanawade/b00617440bce177d2222eeab4e1d91fe to your computer and use it in GitHub Desktop.
GSoC '22 Final Report: Casbin-rs

GSoC Final Report - Casbin-RS

EDIT: CERTIFICATE OF COMPLETION

The certificate of completion of Google Summer of Code 22 at Casbin organisation can be found here

Personal Details

Project Details

Overview

Casbin-RS is now ready for production

With the efforts of Casbin Community, the Rust version of the Casbin is now ready for production. Casbin-RS can provide access control with blazing fast speed. In the past months, I have developed axum-casbin-auth which is a Casbin access control middleware for axum framework. To understand the implementation of axum-casbin-auth, I have also added a axum-middleware-example, which is a real world based example demonstrating usage of axum-casbin-auth with real applications. All the applications which I worked on now have Github Action CI setup which ensure proper PR checks.

Casbin-RS is now ready for Axum-web Development

Axum is a web application framework that focuses on ergonomics and modularity. Axum doesn't have its own middleware system, but instead it uses tower::Service. This means axum gets timeouts, tracing, compression, authorization and other compatible tower functionalities for free. It also enables you to share middleware with applications written using hyper or tonic. In the past months, I had been working on integrating Casbin with Axum-web framework.

With axum-casbin-auth, we can now have a basic middleware to handle requests with authorization control. It can basically read username, request path, request method from an user request and send enforce request (sub, domain, obj, act) to casbin enforcer for authorization.

Casbin Axum-web Real World App is a fully functional demo which intergrated with Axum-web, Casbin Axum-web Middleware , Diesel, Casbin Diesel Adaper. The example demonstrates the authorization at some hospital where doctor has write access to report of patient where as patient has read access only. With the intergration of casbin, it can authorize the requests and add policies when new user registered. The application can act as an example for developers to use casbin with axum-web.

My contributions

axum-casbin-auth

Repository: https://github.com/casbin-rs/axum-casbin-auth

Tasks:

  • CI/CD Intergrations: Github Actions
  • Basic Funtion Implementation and axum-middleware template
  • Add support for AuthN middleware with casbin and axum
  • Support Get/Set enforcer for Flexible demand
  • Test module for middleware
  • Add readme file

Contributions:

Is repository ready for public use? Yes

axum-middleware-example

Repository: https://github.com/casbin-rs/axum-middleware-example

Tasks:

  • CI/CD Intergrations: Github Actions
  • Database Design and Migration Implement
  • Implement various utils for password hashing and token validation
  • Intergration with Casbin Axum-web Middleware
  • User JWT Authentication Middleware Implementation
  • Casbin Configuration and Structure Design
  • Preset Policy Databse Initial Implementation
  • Restful API Implementation using Axum-web
  • Blog writing
  • Refactoring the module into separate repository

Contributions:

NOTE: The original repository, casbin-rs/examples became too big and for ease in maintainance it was decided to break this repository into smaller repositories and casbin-rs/axum-middleware-example is one of them. Following is the old PR: \

Is repository ready for public use? Yes

casbin-grpc

Repository: https://github.com/casbin-rs/casbin-grpc

Tasks:

  • CI/CD Intergrations: Github Actions
  • Update prost, tonic.
  • Migrate repository to Rust 2021 from Rust 2018
  • Dereference the CachedEnforcer so as to call standard enforce functions.
  • Ensure thread safety of CachedEnforcer
  • Add the management APIs with reference to proto.rs
  • Resolve enforcer(m, a) error
  • Resolve errors in various parts of code due to deprecated code, improper reference to variables or borrow.
  • Implement datastructure similar to HashMaps.
  • Ensure thread safety of Box
  • Dereference Box

Contributions:

NOTE: The original PR became too long and hence I had to break down the PR into small PRs according to tasks. The original PR is now closed.

Long PR: fix: Make casbin-grpc run

Is repository ready for public use? No, but there has been lot of improvements in the application and now fewer tasks are to be accomplished before we can host casbin-grpc server.

Refactoring of casbin-rs/examples:

The casbin-rs/examples repository had become pretty large and it was causing pain in maintaining such a large repository due to different examples which were causing version conflicts. The following PR is closed now, its main objective was to make casbin-rs/examples compile and add axum-middleware-example to the repsository.

The older PR can be found at: fix: Update dependencies, ensure build success and add axum-middleware-example

actix-middleware-example

Repository: https://github.com/casbin-rs/actix-middleware-example

Tasks:

  • CI/CD Intergrations: Github Actions
  • Update the dependencies to latest version
  • Migrate repository to Rust 2021 from Rust 2018
  • Resolve version conflict between async-std and tokio
  • Make build success and remove deprecated code
  • Refactor the module into repository and contribute in small PRs to ensure ease in maintaining repository

Contributions:

Is repository ready for public use? Yes

actix-fileadapter-rbac

Repository: https://github.com/casbin-rs/actix-file-adapter-rbac

Tasks:

  • CI/CD Intergrations: Github Actions
  • Update the dependencies to latest version
  • Migrate repository to Rust 2021 from Rust 2018
  • Make build success and remove deprecated code
  • Refactor the module into repository and contribute in small PRs to ensure ease in maintaining repository

Contributions:

Is repository ready for public use? Yes

actix-pgsql-simple

Repository: https://github.com/casbin-rs/actix-postgresql-simple

Tasks:

  • CI/CD Intergrations: Github Actions
  • Update the dependencies to latest version
  • Migrate repository to Rust 2021 from Rust 2018
  • Refactor the module into repository and contribute in small PRs to ensure ease in maintaining repository

Contributions:

Is repository ready for public use? Yes

ntex-fileadapter-acl

Repository: https://github.com/casbin-rs/ntex-file-adapter-acl

Tasks:

  • CI/CD Intergrations: Github Actions
  • Update the dependencies to latest version
  • Migrate repository to Rust 2021 from Rust 2018
  • Added tokio feature in ntex which was required for present version of ntex
  • Refactor the module into repository and contribute in small PRs to ensure ease in maintaining repository

Contributions:

Is repository ready for public use? Yes

poem-todo

Repository: https://github.com/casbin-rs/poem-todo

Tasks:

  • CI/CD Intergrations: Github Actions
  • Refactor the module into repository and contribute in small PRs to ensure ease in maintaining repository

Contributions:

Is repository ready for public use? Yes

Other contributions

sqlx-adapter

  1. Update the sqlx version and resolve the postgres issue on windows and macOS platforms PR: feat: update sqlx version to 0.6

  2. Fix the Auto Coverage error PR: fix: Auto Coverage Error

actix-casbin-auth

  1. Update the Readme PR: fix: corrected the readme file

actix-casbin

  1. Update the tokio version, since it was causing tokio version conflict in casbin-rs/actix-middleware-example(then: casbin-rs/examples) PR: fix: Update tokio

Added pointers to newly developed ecosystems in casbin-rs

  1. Axum PR: feat: Add axum-casbin-auth and axum-middleware-example

  2. Poem PR: feat: Request to add poem-casbin in examples of community use

After GSoC

It was a great experience while contributing to Casbin. The learning curve was great and I wish to contibue contributions to the community. Following are the temporary post GSoC plans

  1. Work on casbin-openraft
  2. Continue maintaining the existing repositories
  3. Write documentaions and develop tutorials for casbin ecosystem.

Experience

Entire GSoC journey was full of ups and downs. There were days when I got stuck on some stuff for days and suddenly out of nowhere something strikes and I make progress, it taught me to hold patience and importance of open source community. Mentors and OrgAdmin were supportive and available whenever I needed them. I thank my mentors for making the entire journey beautiful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment