2024-11-12T02:51:46,883 Created temporary directory: /tmp/pip-build-tracker-mzgol1lj 2024-11-12T02:51:46,884 Initialized build tracking at /tmp/pip-build-tracker-mzgol1lj 2024-11-12T02:51:46,885 Created build tracker: /tmp/pip-build-tracker-mzgol1lj 2024-11-12T02:51:46,885 Entered build tracker: /tmp/pip-build-tracker-mzgol1lj 2024-11-12T02:51:46,886 Created temporary directory: /tmp/pip-wheel-0aewhssa 2024-11-12T02:51:46,890 Created temporary directory: /tmp/pip-ephem-wheel-cache-ywec4oid 2024-11-12T02:51:46,934 Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple 2024-11-12T02:51:46,937 2 location(s) to search for versions of fastapi-casbin-auth: 2024-11-12T02:51:46,937 * https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:46,937 * https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:46,938 Fetching project page and analyzing links: https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:46,938 Getting page https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:46,940 Found index url https://pypi.org/simple/ 2024-11-12T02:51:47,085 Fetched page https://pypi.org/simple/fastapi-casbin-auth/ as application/vnd.pypi.simple.v1+json 2024-11-12T02:51:47,087 Skipping link: No binaries permitted for fastapi-casbin-auth: https://files.pythonhosted.org/packages/26/6f/ed8983cfacaff21ee5b00bb4b4956e94173f4f34b5d43996a08548cb5f3d/fastapi_casbin_auth-1.0.0-py3-none-any.whl (from https://pypi.org/simple/fastapi-casbin-auth/) (requires-python:>=3.6) 2024-11-12T02:51:47,088 Found link https://files.pythonhosted.org/packages/27/dc/231c89d63933efef394c116496dc9a2dfc06c4afad2018d07e7a752a210e/fastapi_casbin_auth-1.0.0.tar.gz (from https://pypi.org/simple/fastapi-casbin-auth/) (requires-python:>=3.6), version: 1.0.0 2024-11-12T02:51:47,088 Skipping link: No binaries permitted for fastapi-casbin-auth: https://files.pythonhosted.org/packages/a7/ce/4c9d8c38ac54ac8db8925cd22642e24a132feb29a996576adea8b51b67f1/fastapi_casbin_auth-1.1.0-py3-none-any.whl (from https://pypi.org/simple/fastapi-casbin-auth/) (requires-python:>=3.6) 2024-11-12T02:51:47,090 Found link https://files.pythonhosted.org/packages/0f/95/f53a9b697d665bff1a84b7367d1a947608852402358cf04ef31ad2532ea3/fastapi_casbin_auth-1.1.0.tar.gz (from https://pypi.org/simple/fastapi-casbin-auth/) (requires-python:>=3.6), version: 1.1.0 2024-11-12T02:51:47,090 Skipping link: No binaries permitted for fastapi-casbin-auth: https://files.pythonhosted.org/packages/0e/95/f915de6d877cbe8608fe41f55ea796ccbab5f61869819356bfed5d5711f8/fastapi_casbin_auth-1.2.0-py3-none-any.whl (from https://pypi.org/simple/fastapi-casbin-auth/) (requires-python:>=3.6) 2024-11-12T02:51:47,091 Found link https://files.pythonhosted.org/packages/2d/70/c023a165d83aab3b0d9253f8a70979e9aa671ef49b94fdf7050da3e42f01/fastapi_casbin_auth-1.2.0.tar.gz (from https://pypi.org/simple/fastapi-casbin-auth/) (requires-python:>=3.6), version: 1.2.0 2024-11-12T02:51:47,092 Fetching project page and analyzing links: https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:47,093 Getting page https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:47,094 Found index url https://www.piwheels.org/simple/ 2024-11-12T02:51:47,256 Fetched page https://www.piwheels.org/simple/fastapi-casbin-auth/ as text/html 2024-11-12T02:51:47,257 Skipping link: not a file: https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:47,258 Skipping link: not a file: https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:47,277 Given no hashes to check 1 links for project 'fastapi-casbin-auth': discarding no candidates 2024-11-12T02:51:47,278 Collecting fastapi-casbin-auth==1.2.0 2024-11-12T02:51:47,281 Created temporary directory: /tmp/pip-unpack-owmuqyxv 2024-11-12T02:51:47,495 Downloading fastapi_casbin_auth-1.2.0.tar.gz (8.9 kB) 2024-11-12T02:51:47,531 Added fastapi-casbin-auth==1.2.0 from https://files.pythonhosted.org/packages/2d/70/c023a165d83aab3b0d9253f8a70979e9aa671ef49b94fdf7050da3e42f01/fastapi_casbin_auth-1.2.0.tar.gz to build tracker '/tmp/pip-build-tracker-mzgol1lj' 2024-11-12T02:51:47,533 Running setup.py (path:/tmp/pip-wheel-0aewhssa/fastapi-casbin-auth_11c977543f2040a5890400f058fff7cd/setup.py) egg_info for package fastapi-casbin-auth 2024-11-12T02:51:47,534 Created temporary directory: /tmp/pip-pip-egg-info-tiuayiwd 2024-11-12T02:51:47,535 Preparing metadata (setup.py): started 2024-11-12T02:51:47,536 Running command python setup.py egg_info 2024-11-12T02:51:48,651 # fastapi-casbin-auth 2024-11-12T02:51:48,651 [![Build Status](https://github.com/officialpycasbin/fastapi-casbin-auth/actions/workflows/release.yml/badge.svg)](https://github.com/officialpycasbin/fastapi-casbin-auth/actions/workflows/release.yml) 2024-11-12T02:51:48,652 [![Coverage Status](https://coveralls.io/repos/github/officialpycasbin/fastapi-casbin-auth/badge.svg)](https://coveralls.io/github/officialpycasbin/fastapi-casbin-auth) 2024-11-12T02:51:48,652 [![Version](https://img.shields.io/pypi/v/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:48,653 [![PyPI - Wheel](https://img.shields.io/pypi/wheel/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:48,653 [![Pyversions](https://img.shields.io/pypi/pyversions/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:48,654 [![Download](https://img.shields.io/pypi/dm/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:48,654 [![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN) 2024-11-12T02:51:48,655 fastapi-casbin-auth is an authorization middleware for [FastAPI](https://fastapi.tiangolo.com/), it's based on [PyCasbin](https://github.com/casbin/pycasbin). 2024-11-12T02:51:48,656 ## Installation 2024-11-12T02:51:48,657 Install from pip 2024-11-12T02:51:48,658 ```bash 2024-11-12T02:51:48,659 pip install fastapi-casbin-auth 2024-11-12T02:51:48,659 ``` 2024-11-12T02:51:48,660 Clone this repo 2024-11-12T02:51:48,661 ```bash 2024-11-12T02:51:48,662 git clone https://github.com/officialpycasbin/fastapi-casbin-auth.git 2024-11-12T02:51:48,662 python setup.py install 2024-11-12T02:51:48,663 ``` 2024-11-12T02:51:48,664 ## Quickstart 2024-11-12T02:51:48,665 This middleware is designed to work with another middleware which implement `AuthenticationMiddleware` interface. 2024-11-12T02:51:48,666 ```python 2024-11-12T02:51:48,666 import base64 2024-11-12T02:51:48,667 import binascii 2024-11-12T02:51:48,668 import casbin 2024-11-12T02:51:48,669 from fastapi import FastAPI 2024-11-12T02:51:48,669 from starlette.authentication import AuthenticationBackend, AuthenticationError, SimpleUser, AuthCredentials 2024-11-12T02:51:48,670 from starlette.middleware.authentication import AuthenticationMiddleware 2024-11-12T02:51:48,671 from fastapi_casbin_auth import CasbinMiddleware 2024-11-12T02:51:48,672 app = FastAPI() 2024-11-12T02:51:48,674 class BasicAuth(AuthenticationBackend): 2024-11-12T02:51:48,675 async def authenticate(self, request): 2024-11-12T02:51:48,675 if "Authorization" not in request.headers: 2024-11-12T02:51:48,676 return None 2024-11-12T02:51:48,677 auth = request.headers["Authorization"] 2024-11-12T02:51:48,677 try: 2024-11-12T02:51:48,678 scheme, credentials = auth.split() 2024-11-12T02:51:48,679 decoded = base64.b64decode(credentials).decode("ascii") 2024-11-12T02:51:48,679 except (ValueError, UnicodeDecodeError, binascii.Error): 2024-11-12T02:51:48,680 raise AuthenticationError("Invalid basic auth credentials") 2024-11-12T02:51:48,681 username, _, password = decoded.partition(":") 2024-11-12T02:51:48,681 return AuthCredentials(["authenticated"]), SimpleUser(username) 2024-11-12T02:51:48,683 enforcer = casbin.Enforcer('../examples/rbac_model.conf', '../examples/rbac_policy.csv') 2024-11-12T02:51:48,684 app.add_middleware(CasbinMiddleware, enforcer=enforcer) 2024-11-12T02:51:48,685 app.add_middleware(AuthenticationMiddleware, backend=BasicAuth()) 2024-11-12T02:51:48,686 @app.get('/') 2024-11-12T02:51:48,687 async def index(): 2024-11-12T02:51:48,687 return "If you see this, you have been authenticated." 2024-11-12T02:51:48,689 @app.get('/dataset1/protected') 2024-11-12T02:51:48,690 async def auth_test(): 2024-11-12T02:51:48,690 return "You must be alice to see this." 2024-11-12T02:51:48,690 ``` 2024-11-12T02:51:48,691 - anonymous request 2024-11-12T02:51:48,692 ```bash 2024-11-12T02:51:48,693 curl -i http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:48,693 ``` 2024-11-12T02:51:48,694 ```bash 2024-11-12T02:51:48,695 HTTP/1.1 403 Forbidden 2024-11-12T02:51:48,695 date: Mon, 01 Mar 2021 09:00:08 GMT 2024-11-12T02:51:48,696 server: uvicorn 2024-11-12T02:51:48,696 content-length: 11 2024-11-12T02:51:48,697 content-type: application/json 2024-11-12T02:51:48,698 "Forbidden" 2024-11-12T02:51:48,698 ``` 2024-11-12T02:51:48,699 - authenticated request 2024-11-12T02:51:48,700 ```bash 2024-11-12T02:51:48,701 curl -i -u alice:password http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:48,701 ``` 2024-11-12T02:51:48,702 ```bash 2024-11-12T02:51:48,703 HTTP/1.1 200 OK 2024-11-12T02:51:48,703 date: Mon, 01 Mar 2021 09:04:54 GMT 2024-11-12T02:51:48,704 server: uvicorn 2024-11-12T02:51:48,704 content-length: 32 2024-11-12T02:51:48,705 content-type: application/json 2024-11-12T02:51:48,706 "You must be alice to see this." 2024-11-12T02:51:48,706 ``` 2024-11-12T02:51:48,707 It used the casbin config from `examples` folder, and you can find this demo in `demo` folder. 2024-11-12T02:51:48,708 You can also view the unit tests to understand this middleware. 2024-11-12T02:51:48,710 Besides, there is another example for `CasbinMiddleware` which is designed to work with JWT authentication. You can find 2024-11-12T02:51:48,710 it in `demo/jwt_test.py`. 2024-11-12T02:51:48,711 ## Development 2024-11-12T02:51:48,712 ### Run unit tests 2024-11-12T02:51:48,713 1. Fork/Clone repository 2024-11-12T02:51:48,714 2. Install fastapi-casbin-auth dependencies, and run `pytest` 2024-11-12T02:51:48,715 ```bash 2024-11-12T02:51:48,716 pip install -r dev_requirements.txt 2024-11-12T02:51:48,716 pip install -r requirements.txt 2024-11-12T02:51:48,717 pytest 2024-11-12T02:51:48,717 ``` 2024-11-12T02:51:48,718 ### Update requirements with pip-tools 2024-11-12T02:51:48,720 ```bash 2024-11-12T02:51:48,720 # update requirements.txt 2024-11-12T02:51:48,721 pip-compile --no-annotate --no-header --rebuild requirements.in 2024-11-12T02:51:48,721 # sync venv 2024-11-12T02:51:48,722 pip-sync 2024-11-12T02:51:48,722 ``` 2024-11-12T02:51:48,723 ### Manually Bump Version 2024-11-12T02:51:48,725 ``` 2024-11-12T02:51:48,725 bumpversion major # major release 2024-11-12T02:51:48,726 or 2024-11-12T02:51:48,726 bumpversion minor # minor release 2024-11-12T02:51:48,727 or 2024-11-12T02:51:48,727 bumpversion patch # hotfix release 2024-11-12T02:51:48,728 ``` 2024-11-12T02:51:48,729 ## Documentation 2024-11-12T02:51:48,730 The authorization determines a request based on ``{subject, object, action}``, which means what ``subject`` can perform 2024-11-12T02:51:48,731 what ``action`` on what ``object``. In this plugin, the meanings are: 2024-11-12T02:51:48,732 1. ``subject``: the logged-in user name 2024-11-12T02:51:48,732 2. ``object``: the URL path for the web resource like `dataset1/item1` 2024-11-12T02:51:48,733 3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like "read-file", " 2024-11-12T02:51:48,734 write-blog" (currently no official support in this middleware) 2024-11-12T02:51:48,735 For how to write authorization policy and other details, please refer 2024-11-12T02:51:48,736 to [the Casbin's documentation](https://casbin.org). 2024-11-12T02:51:48,737 ## Getting Help 2024-11-12T02:51:48,738 - [Casbin](https://casbin.org) 2024-11-12T02:51:48,739 ## License 2024-11-12T02:51:48,740 This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text. 2024-11-12T02:51:48,741 running egg_info 2024-11-12T02:51:48,741 creating /tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info 2024-11-12T02:51:48,742 writing /tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/PKG-INFO 2024-11-12T02:51:48,742 writing dependency_links to /tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/dependency_links.txt 2024-11-12T02:51:48,743 writing requirements to /tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/requires.txt 2024-11-12T02:51:48,743 writing top-level names to /tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/top_level.txt 2024-11-12T02:51:48,744 writing manifest file '/tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:48,787 reading manifest file '/tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:48,789 adding license file 'LICENSE' 2024-11-12T02:51:48,791 writing manifest file '/tmp/pip-pip-egg-info-tiuayiwd/fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:48,900 Preparing metadata (setup.py): finished with status 'done' 2024-11-12T02:51:48,904 Source in /tmp/pip-wheel-0aewhssa/fastapi-casbin-auth_11c977543f2040a5890400f058fff7cd has version 1.2.0, which satisfies requirement fastapi-casbin-auth==1.2.0 from https://files.pythonhosted.org/packages/2d/70/c023a165d83aab3b0d9253f8a70979e9aa671ef49b94fdf7050da3e42f01/fastapi_casbin_auth-1.2.0.tar.gz 2024-11-12T02:51:48,905 Removed fastapi-casbin-auth==1.2.0 from https://files.pythonhosted.org/packages/2d/70/c023a165d83aab3b0d9253f8a70979e9aa671ef49b94fdf7050da3e42f01/fastapi_casbin_auth-1.2.0.tar.gz from build tracker '/tmp/pip-build-tracker-mzgol1lj' 2024-11-12T02:51:48,911 Created temporary directory: /tmp/pip-unpack-am4ev7du 2024-11-12T02:51:48,912 Created temporary directory: /tmp/pip-unpack-7o7vidwa 2024-11-12T02:51:48,913 Building wheels for collected packages: fastapi-casbin-auth 2024-11-12T02:51:48,917 Created temporary directory: /tmp/pip-wheel-gtrb292q 2024-11-12T02:51:48,918 Building wheel for fastapi-casbin-auth (setup.py): started 2024-11-12T02:51:48,919 Destination directory: /tmp/pip-wheel-gtrb292q 2024-11-12T02:51:48,920 Running command python setup.py bdist_wheel 2024-11-12T02:51:49,417 # fastapi-casbin-auth 2024-11-12T02:51:49,417 [![Build Status](https://github.com/officialpycasbin/fastapi-casbin-auth/actions/workflows/release.yml/badge.svg)](https://github.com/officialpycasbin/fastapi-casbin-auth/actions/workflows/release.yml) 2024-11-12T02:51:49,418 [![Coverage Status](https://coveralls.io/repos/github/officialpycasbin/fastapi-casbin-auth/badge.svg)](https://coveralls.io/github/officialpycasbin/fastapi-casbin-auth) 2024-11-12T02:51:49,419 [![Version](https://img.shields.io/pypi/v/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:49,419 [![PyPI - Wheel](https://img.shields.io/pypi/wheel/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:49,420 [![Pyversions](https://img.shields.io/pypi/pyversions/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:49,421 [![Download](https://img.shields.io/pypi/dm/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:49,421 [![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN) 2024-11-12T02:51:49,423 fastapi-casbin-auth is an authorization middleware for [FastAPI](https://fastapi.tiangolo.com/), it's based on [PyCasbin](https://github.com/casbin/pycasbin). 2024-11-12T02:51:49,424 ## Installation 2024-11-12T02:51:49,425 Install from pip 2024-11-12T02:51:49,426 ```bash 2024-11-12T02:51:49,427 pip install fastapi-casbin-auth 2024-11-12T02:51:49,427 ``` 2024-11-12T02:51:49,429 Clone this repo 2024-11-12T02:51:49,430 ```bash 2024-11-12T02:51:49,431 git clone https://github.com/officialpycasbin/fastapi-casbin-auth.git 2024-11-12T02:51:49,431 python setup.py install 2024-11-12T02:51:49,431 ``` 2024-11-12T02:51:49,432 ## Quickstart 2024-11-12T02:51:49,433 This middleware is designed to work with another middleware which implement `AuthenticationMiddleware` interface. 2024-11-12T02:51:49,434 ```python 2024-11-12T02:51:49,435 import base64 2024-11-12T02:51:49,435 import binascii 2024-11-12T02:51:49,436 import casbin 2024-11-12T02:51:49,437 from fastapi import FastAPI 2024-11-12T02:51:49,438 from starlette.authentication import AuthenticationBackend, AuthenticationError, SimpleUser, AuthCredentials 2024-11-12T02:51:49,438 from starlette.middleware.authentication import AuthenticationMiddleware 2024-11-12T02:51:49,439 from fastapi_casbin_auth import CasbinMiddleware 2024-11-12T02:51:49,440 app = FastAPI() 2024-11-12T02:51:49,441 class BasicAuth(AuthenticationBackend): 2024-11-12T02:51:49,442 async def authenticate(self, request): 2024-11-12T02:51:49,442 if "Authorization" not in request.headers: 2024-11-12T02:51:49,443 return None 2024-11-12T02:51:49,443 auth = request.headers["Authorization"] 2024-11-12T02:51:49,444 try: 2024-11-12T02:51:49,444 scheme, credentials = auth.split() 2024-11-12T02:51:49,445 decoded = base64.b64decode(credentials).decode("ascii") 2024-11-12T02:51:49,445 except (ValueError, UnicodeDecodeError, binascii.Error): 2024-11-12T02:51:49,446 raise AuthenticationError("Invalid basic auth credentials") 2024-11-12T02:51:49,447 username, _, password = decoded.partition(":") 2024-11-12T02:51:49,448 return AuthCredentials(["authenticated"]), SimpleUser(username) 2024-11-12T02:51:49,450 enforcer = casbin.Enforcer('../examples/rbac_model.conf', '../examples/rbac_policy.csv') 2024-11-12T02:51:49,451 app.add_middleware(CasbinMiddleware, enforcer=enforcer) 2024-11-12T02:51:49,451 app.add_middleware(AuthenticationMiddleware, backend=BasicAuth()) 2024-11-12T02:51:49,454 @app.get('/') 2024-11-12T02:51:49,454 async def index(): 2024-11-12T02:51:49,455 return "If you see this, you have been authenticated." 2024-11-12T02:51:49,457 @app.get('/dataset1/protected') 2024-11-12T02:51:49,457 async def auth_test(): 2024-11-12T02:51:49,458 return "You must be alice to see this." 2024-11-12T02:51:49,458 ``` 2024-11-12T02:51:49,460 - anonymous request 2024-11-12T02:51:49,461 ```bash 2024-11-12T02:51:49,462 curl -i http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:49,462 ``` 2024-11-12T02:51:49,464 ```bash 2024-11-12T02:51:49,464 HTTP/1.1 403 Forbidden 2024-11-12T02:51:49,465 date: Mon, 01 Mar 2021 09:00:08 GMT 2024-11-12T02:51:49,466 server: uvicorn 2024-11-12T02:51:49,466 content-length: 11 2024-11-12T02:51:49,467 content-type: application/json 2024-11-12T02:51:49,468 "Forbidden" 2024-11-12T02:51:49,468 ``` 2024-11-12T02:51:49,469 - authenticated request 2024-11-12T02:51:49,471 ```bash 2024-11-12T02:51:49,471 curl -i -u alice:password http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:49,472 ``` 2024-11-12T02:51:49,473 ```bash 2024-11-12T02:51:49,474 HTTP/1.1 200 OK 2024-11-12T02:51:49,474 date: Mon, 01 Mar 2021 09:04:54 GMT 2024-11-12T02:51:49,475 server: uvicorn 2024-11-12T02:51:49,475 content-length: 32 2024-11-12T02:51:49,476 content-type: application/json 2024-11-12T02:51:49,477 "You must be alice to see this." 2024-11-12T02:51:49,478 ``` 2024-11-12T02:51:49,479 It used the casbin config from `examples` folder, and you can find this demo in `demo` folder. 2024-11-12T02:51:49,480 You can also view the unit tests to understand this middleware. 2024-11-12T02:51:49,481 Besides, there is another example for `CasbinMiddleware` which is designed to work with JWT authentication. You can find 2024-11-12T02:51:49,482 it in `demo/jwt_test.py`. 2024-11-12T02:51:49,483 ## Development 2024-11-12T02:51:49,484 ### Run unit tests 2024-11-12T02:51:49,486 1. Fork/Clone repository 2024-11-12T02:51:49,486 2. Install fastapi-casbin-auth dependencies, and run `pytest` 2024-11-12T02:51:49,487 ```bash 2024-11-12T02:51:49,488 pip install -r dev_requirements.txt 2024-11-12T02:51:49,488 pip install -r requirements.txt 2024-11-12T02:51:49,488 pytest 2024-11-12T02:51:49,489 ``` 2024-11-12T02:51:49,490 ### Update requirements with pip-tools 2024-11-12T02:51:49,491 ```bash 2024-11-12T02:51:49,491 # update requirements.txt 2024-11-12T02:51:49,492 pip-compile --no-annotate --no-header --rebuild requirements.in 2024-11-12T02:51:49,492 # sync venv 2024-11-12T02:51:49,493 pip-sync 2024-11-12T02:51:49,493 ``` 2024-11-12T02:51:49,494 ### Manually Bump Version 2024-11-12T02:51:49,495 ``` 2024-11-12T02:51:49,496 bumpversion major # major release 2024-11-12T02:51:49,496 or 2024-11-12T02:51:49,497 bumpversion minor # minor release 2024-11-12T02:51:49,497 or 2024-11-12T02:51:49,498 bumpversion patch # hotfix release 2024-11-12T02:51:49,498 ``` 2024-11-12T02:51:49,499 ## Documentation 2024-11-12T02:51:49,500 The authorization determines a request based on ``{subject, object, action}``, which means what ``subject`` can perform 2024-11-12T02:51:49,501 what ``action`` on what ``object``. In this plugin, the meanings are: 2024-11-12T02:51:49,501 1. ``subject``: the logged-in user name 2024-11-12T02:51:49,502 2. ``object``: the URL path for the web resource like `dataset1/item1` 2024-11-12T02:51:49,502 3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like "read-file", " 2024-11-12T02:51:49,503 write-blog" (currently no official support in this middleware) 2024-11-12T02:51:49,504 For how to write authorization policy and other details, please refer 2024-11-12T02:51:49,504 to [the Casbin's documentation](https://casbin.org). 2024-11-12T02:51:49,506 ## Getting Help 2024-11-12T02:51:49,507 - [Casbin](https://casbin.org) 2024-11-12T02:51:49,508 ## License 2024-11-12T02:51:49,509 This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text. 2024-11-12T02:51:50,007 running bdist_wheel 2024-11-12T02:51:50,138 running build 2024-11-12T02:51:50,139 running build_py 2024-11-12T02:51:50,169 creating build/lib/fastapi_casbin_auth 2024-11-12T02:51:50,171 copying fastapi_casbin_auth/middleware.py -> build/lib/fastapi_casbin_auth 2024-11-12T02:51:50,173 copying fastapi_casbin_auth/__init__.py -> build/lib/fastapi_casbin_auth 2024-11-12T02:51:50,174 running egg_info 2024-11-12T02:51:50,202 writing fastapi_casbin_auth.egg-info/PKG-INFO 2024-11-12T02:51:50,205 writing dependency_links to fastapi_casbin_auth.egg-info/dependency_links.txt 2024-11-12T02:51:50,207 writing requirements to fastapi_casbin_auth.egg-info/requires.txt 2024-11-12T02:51:50,208 writing top-level names to fastapi_casbin_auth.egg-info/top_level.txt 2024-11-12T02:51:50,241 reading manifest file 'fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:50,243 adding license file 'LICENSE' 2024-11-12T02:51:50,246 writing manifest file 'fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:50,275 /usr/local/lib/python3.11/dist-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. 2024-11-12T02:51:50,276 !! 2024-11-12T02:51:50,277 ******************************************************************************** 2024-11-12T02:51:50,278 Please avoid running ``setup.py`` directly. 2024-11-12T02:51:50,278 Instead, use pypa/build, pypa/installer or other 2024-11-12T02:51:50,279 standards-based tools. 2024-11-12T02:51:50,280 See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. 2024-11-12T02:51:50,281 ******************************************************************************** 2024-11-12T02:51:50,282 !! 2024-11-12T02:51:50,283 self.initialize_options() 2024-11-12T02:51:50,303 installing to build/bdist.linux-armv7l/wheel 2024-11-12T02:51:50,304 running install 2024-11-12T02:51:50,329 running install_lib 2024-11-12T02:51:50,356 creating build/bdist.linux-armv7l/wheel 2024-11-12T02:51:50,358 creating build/bdist.linux-armv7l/wheel/fastapi_casbin_auth 2024-11-12T02:51:50,360 copying build/lib/fastapi_casbin_auth/middleware.py -> build/bdist.linux-armv7l/wheel/./fastapi_casbin_auth 2024-11-12T02:51:50,362 copying build/lib/fastapi_casbin_auth/__init__.py -> build/bdist.linux-armv7l/wheel/./fastapi_casbin_auth 2024-11-12T02:51:50,363 running install_data 2024-11-12T02:51:50,391 creating build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.2.0.data/data 2024-11-12T02:51:50,393 warning: install_data: setup script did not provide a directory for 'README.md' -- installing right in 'build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.2.0.data/data' 2024-11-12T02:51:50,394 copying README.md -> build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.2.0.data/data 2024-11-12T02:51:50,395 warning: install_data: setup script did not provide a directory for 'requirements.txt' -- installing right in 'build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.2.0.data/data' 2024-11-12T02:51:50,396 copying requirements.txt -> build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.2.0.data/data 2024-11-12T02:51:50,398 running install_egg_info 2024-11-12T02:51:50,432 Copying fastapi_casbin_auth.egg-info to build/bdist.linux-armv7l/wheel/./fastapi_casbin_auth-1.2.0-py3.11.egg-info 2024-11-12T02:51:50,442 running install_scripts 2024-11-12T02:51:50,456 creating build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.2.0.dist-info/WHEEL 2024-11-12T02:51:50,458 creating '/tmp/pip-wheel-gtrb292q/fastapi_casbin_auth-1.2.0-py3-none-any.whl' and adding 'build/bdist.linux-armv7l/wheel' to it 2024-11-12T02:51:50,461 adding 'fastapi_casbin_auth/__init__.py' 2024-11-12T02:51:50,462 adding 'fastapi_casbin_auth/middleware.py' 2024-11-12T02:51:50,464 adding 'fastapi_casbin_auth-1.2.0.data/data/README.md' 2024-11-12T02:51:50,466 adding 'fastapi_casbin_auth-1.2.0.data/data/requirements.txt' 2024-11-12T02:51:50,469 adding 'fastapi_casbin_auth-1.2.0.dist-info/LICENSE' 2024-11-12T02:51:50,470 adding 'fastapi_casbin_auth-1.2.0.dist-info/METADATA' 2024-11-12T02:51:50,472 adding 'fastapi_casbin_auth-1.2.0.dist-info/WHEEL' 2024-11-12T02:51:50,473 adding 'fastapi_casbin_auth-1.2.0.dist-info/top_level.txt' 2024-11-12T02:51:50,474 adding 'fastapi_casbin_auth-1.2.0.dist-info/RECORD' 2024-11-12T02:51:50,475 removing build/bdist.linux-armv7l/wheel 2024-11-12T02:51:50,596 Building wheel for fastapi-casbin-auth (setup.py): finished with status 'done' 2024-11-12T02:51:50,599 Created wheel for fastapi-casbin-auth: filename=fastapi_casbin_auth-1.2.0-py3-none-any.whl size=10940 sha256=dba20d4d19bbe0ecd8b3a155a6b482f920988739f144128e999ac0d363c0d6b8 2024-11-12T02:51:50,600 Stored in directory: /tmp/pip-ephem-wheel-cache-ywec4oid/wheels/06/e1/ec/9a128c3c2d158be78c50b9c2097077855d32809dfd2b7931f7 2024-11-12T02:51:50,611 Successfully built fastapi-casbin-auth 2024-11-12T02:51:50,614 Removed build tracker: '/tmp/pip-build-tracker-mzgol1lj'