2024-11-12T02:51:32,538 Created temporary directory: /tmp/pip-build-tracker-y1qdqx25 2024-11-12T02:51:32,539 Initialized build tracking at /tmp/pip-build-tracker-y1qdqx25 2024-11-12T02:51:32,540 Created build tracker: /tmp/pip-build-tracker-y1qdqx25 2024-11-12T02:51:32,540 Entered build tracker: /tmp/pip-build-tracker-y1qdqx25 2024-11-12T02:51:32,541 Created temporary directory: /tmp/pip-wheel-_hh_8b8i 2024-11-12T02:51:32,545 Created temporary directory: /tmp/pip-ephem-wheel-cache-frnkfqhg 2024-11-12T02:51:32,588 Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple 2024-11-12T02:51:32,591 2 location(s) to search for versions of fastapi-casbin-auth: 2024-11-12T02:51:32,591 * https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:32,591 * https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:32,592 Fetching project page and analyzing links: https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:32,593 Getting page https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:32,594 Found index url https://pypi.org/simple/ 2024-11-12T02:51:32,969 Fetched page https://pypi.org/simple/fastapi-casbin-auth/ as application/vnd.pypi.simple.v1+json 2024-11-12T02:51:32,971 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:32,972 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:32,973 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:32,974 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:32,974 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:32,976 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:32,976 Fetching project page and analyzing links: https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:32,977 Getting page https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:32,978 Found index url https://www.piwheels.org/simple/ 2024-11-12T02:51:33,183 Fetched page https://www.piwheels.org/simple/fastapi-casbin-auth/ as text/html 2024-11-12T02:51:33,184 Skipping link: not a file: https://www.piwheels.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:33,185 Skipping link: not a file: https://pypi.org/simple/fastapi-casbin-auth/ 2024-11-12T02:51:33,203 Given no hashes to check 1 links for project 'fastapi-casbin-auth': discarding no candidates 2024-11-12T02:51:33,204 Collecting fastapi-casbin-auth==1.1.0 2024-11-12T02:51:33,207 Created temporary directory: /tmp/pip-unpack-k43csinr 2024-11-12T02:51:33,347 Downloading fastapi_casbin_auth-1.1.0.tar.gz (8.9 kB) 2024-11-12T02:51:33,386 Added fastapi-casbin-auth==1.1.0 from https://files.pythonhosted.org/packages/0f/95/f53a9b697d665bff1a84b7367d1a947608852402358cf04ef31ad2532ea3/fastapi_casbin_auth-1.1.0.tar.gz to build tracker '/tmp/pip-build-tracker-y1qdqx25' 2024-11-12T02:51:33,387 Running setup.py (path:/tmp/pip-wheel-_hh_8b8i/fastapi-casbin-auth_2aaf9e11da054196bd09b37081346546/setup.py) egg_info for package fastapi-casbin-auth 2024-11-12T02:51:33,389 Created temporary directory: /tmp/pip-pip-egg-info-htornmbb 2024-11-12T02:51:33,389 Preparing metadata (setup.py): started 2024-11-12T02:51:33,390 Running command python setup.py egg_info 2024-11-12T02:51:34,445 # fastapi-casbin-auth 2024-11-12T02:51:34,446 [![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:34,446 [![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:34,447 [![Version](https://img.shields.io/pypi/v/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:34,447 [![PyPI - Wheel](https://img.shields.io/pypi/wheel/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:34,448 [![Pyversions](https://img.shields.io/pypi/pyversions/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:34,449 [![Download](https://img.shields.io/pypi/dm/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:34,449 [![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN) 2024-11-12T02:51:34,450 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:34,451 ## Installation 2024-11-12T02:51:34,453 Install from pip 2024-11-12T02:51:34,454 ```bash 2024-11-12T02:51:34,454 pip install fastapi-casbin-auth 2024-11-12T02:51:34,455 ``` 2024-11-12T02:51:34,456 Clone this repo 2024-11-12T02:51:34,457 ```bash 2024-11-12T02:51:34,458 git clone https://github.com/officialpycasbin/fastapi-casbin-auth.git 2024-11-12T02:51:34,458 python setup.py install 2024-11-12T02:51:34,459 ``` 2024-11-12T02:51:34,460 ## Quickstart 2024-11-12T02:51:34,461 This middleware is designed to work with another middleware which implement `AuthenticationMiddleware` interface. 2024-11-12T02:51:34,462 ```python 2024-11-12T02:51:34,463 import base64 2024-11-12T02:51:34,464 import binascii 2024-11-12T02:51:34,465 import casbin 2024-11-12T02:51:34,466 from fastapi import FastAPI 2024-11-12T02:51:34,466 from starlette.authentication import AuthenticationBackend, AuthenticationError, SimpleUser, AuthCredentials 2024-11-12T02:51:34,467 from starlette.middleware.authentication import AuthenticationMiddleware 2024-11-12T02:51:34,468 from fastapi_casbin_auth import CasbinMiddleware 2024-11-12T02:51:34,469 app = FastAPI() 2024-11-12T02:51:34,471 class BasicAuth(AuthenticationBackend): 2024-11-12T02:51:34,472 async def authenticate(self, request): 2024-11-12T02:51:34,472 if "Authorization" not in request.headers: 2024-11-12T02:51:34,473 return None 2024-11-12T02:51:34,474 auth = request.headers["Authorization"] 2024-11-12T02:51:34,475 try: 2024-11-12T02:51:34,475 scheme, credentials = auth.split() 2024-11-12T02:51:34,476 decoded = base64.b64decode(credentials).decode("ascii") 2024-11-12T02:51:34,476 except (ValueError, UnicodeDecodeError, binascii.Error): 2024-11-12T02:51:34,477 raise AuthenticationError("Invalid basic auth credentials") 2024-11-12T02:51:34,478 username, _, password = decoded.partition(":") 2024-11-12T02:51:34,478 return AuthCredentials(["authenticated"]), SimpleUser(username) 2024-11-12T02:51:34,480 enforcer = casbin.Enforcer('../examples/rbac_model.conf', '../examples/rbac_policy.csv') 2024-11-12T02:51:34,481 app.add_middleware(CasbinMiddleware, enforcer=enforcer) 2024-11-12T02:51:34,482 app.add_middleware(AuthenticationMiddleware, backend=BasicAuth()) 2024-11-12T02:51:34,484 @app.get('/') 2024-11-12T02:51:34,484 async def index(): 2024-11-12T02:51:34,485 return "If you see this, you have been authenticated." 2024-11-12T02:51:34,486 @app.get('/dataset1/protected') 2024-11-12T02:51:34,487 async def auth_test(): 2024-11-12T02:51:34,487 return "You must be alice to see this." 2024-11-12T02:51:34,488 ``` 2024-11-12T02:51:34,489 - anonymous request 2024-11-12T02:51:34,490 ```bash 2024-11-12T02:51:34,490 curl -i http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:34,491 ``` 2024-11-12T02:51:34,492 ```bash 2024-11-12T02:51:34,492 HTTP/1.1 403 Forbidden 2024-11-12T02:51:34,493 date: Mon, 01 Mar 2021 09:00:08 GMT 2024-11-12T02:51:34,493 server: uvicorn 2024-11-12T02:51:34,494 content-length: 11 2024-11-12T02:51:34,494 content-type: application/json 2024-11-12T02:51:34,495 "Forbidden" 2024-11-12T02:51:34,496 ``` 2024-11-12T02:51:34,497 - authenticated request 2024-11-12T02:51:34,498 ```bash 2024-11-12T02:51:34,498 curl -i -u alice:password http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:34,499 ``` 2024-11-12T02:51:34,500 ```bash 2024-11-12T02:51:34,501 HTTP/1.1 200 OK 2024-11-12T02:51:34,501 date: Mon, 01 Mar 2021 09:04:54 GMT 2024-11-12T02:51:34,502 server: uvicorn 2024-11-12T02:51:34,502 content-length: 32 2024-11-12T02:51:34,503 content-type: application/json 2024-11-12T02:51:34,504 "You must be alice to see this." 2024-11-12T02:51:34,504 ``` 2024-11-12T02:51:34,505 It used the casbin config from `examples` folder, and you can find this demo in `demo` folder. 2024-11-12T02:51:34,506 You can also view the unit tests to understand this middleware. 2024-11-12T02:51:34,508 Besides, there is another example for `CasbinMiddleware` which is designed to work with JWT authentication. You can find 2024-11-12T02:51:34,508 it in `demo/jwt_test.py`. 2024-11-12T02:51:34,509 ## Development 2024-11-12T02:51:34,510 ### Run unit tests 2024-11-12T02:51:34,512 1. Fork/Clone repository 2024-11-12T02:51:34,513 2. Install fastapi-casbin-auth dependencies, and run `pytest` 2024-11-12T02:51:34,514 ```bash 2024-11-12T02:51:34,514 pip install -r dev_requirements.txt 2024-11-12T02:51:34,515 pip install -r requirements.txt 2024-11-12T02:51:34,515 pytest 2024-11-12T02:51:34,516 ``` 2024-11-12T02:51:34,517 ### Update requirements with pip-tools 2024-11-12T02:51:34,518 ```bash 2024-11-12T02:51:34,519 # update requirements.txt 2024-11-12T02:51:34,520 pip-compile --no-annotate --no-header --rebuild requirements.in 2024-11-12T02:51:34,520 # sync venv 2024-11-12T02:51:34,521 pip-sync 2024-11-12T02:51:34,521 ``` 2024-11-12T02:51:34,522 ### Manually Bump Version 2024-11-12T02:51:34,523 ``` 2024-11-12T02:51:34,524 bumpversion major # major release 2024-11-12T02:51:34,525 or 2024-11-12T02:51:34,525 bumpversion minor # minor release 2024-11-12T02:51:34,526 or 2024-11-12T02:51:34,527 bumpversion patch # hotfix release 2024-11-12T02:51:34,527 ``` 2024-11-12T02:51:34,528 ## Documentation 2024-11-12T02:51:34,529 The authorization determines a request based on ``{subject, object, action}``, which means what ``subject`` can perform 2024-11-12T02:51:34,530 what ``action`` on what ``object``. In this plugin, the meanings are: 2024-11-12T02:51:34,531 1. ``subject``: the logged-in user name 2024-11-12T02:51:34,532 2. ``object``: the URL path for the web resource like `dataset1/item1` 2024-11-12T02:51:34,532 3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like "read-file", " 2024-11-12T02:51:34,533 write-blog" (currently no official support in this middleware) 2024-11-12T02:51:34,534 For how to write authorization policy and other details, please refer 2024-11-12T02:51:34,535 to [the Casbin's documentation](https://casbin.org). 2024-11-12T02:51:34,536 ## Getting Help 2024-11-12T02:51:34,537 - [Casbin](https://casbin.org) 2024-11-12T02:51:34,538 ## License 2024-11-12T02:51:34,539 This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text. 2024-11-12T02:51:34,540 running egg_info 2024-11-12T02:51:34,541 creating /tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info 2024-11-12T02:51:34,541 writing /tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/PKG-INFO 2024-11-12T02:51:34,542 writing dependency_links to /tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/dependency_links.txt 2024-11-12T02:51:34,542 writing requirements to /tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/requires.txt 2024-11-12T02:51:34,543 writing top-level names to /tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/top_level.txt 2024-11-12T02:51:34,543 writing manifest file '/tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:34,583 reading manifest file '/tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:34,584 adding license file 'LICENSE' 2024-11-12T02:51:34,587 writing manifest file '/tmp/pip-pip-egg-info-htornmbb/fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:34,694 Preparing metadata (setup.py): finished with status 'done' 2024-11-12T02:51:34,699 Source in /tmp/pip-wheel-_hh_8b8i/fastapi-casbin-auth_2aaf9e11da054196bd09b37081346546 has version 1.1.0, which satisfies requirement fastapi-casbin-auth==1.1.0 from https://files.pythonhosted.org/packages/0f/95/f53a9b697d665bff1a84b7367d1a947608852402358cf04ef31ad2532ea3/fastapi_casbin_auth-1.1.0.tar.gz 2024-11-12T02:51:34,700 Removed fastapi-casbin-auth==1.1.0 from https://files.pythonhosted.org/packages/0f/95/f53a9b697d665bff1a84b7367d1a947608852402358cf04ef31ad2532ea3/fastapi_casbin_auth-1.1.0.tar.gz from build tracker '/tmp/pip-build-tracker-y1qdqx25' 2024-11-12T02:51:34,706 Created temporary directory: /tmp/pip-unpack-dinocow1 2024-11-12T02:51:34,707 Created temporary directory: /tmp/pip-unpack-m2w3c9o_ 2024-11-12T02:51:34,708 Building wheels for collected packages: fastapi-casbin-auth 2024-11-12T02:51:34,712 Created temporary directory: /tmp/pip-wheel-el9qr_d3 2024-11-12T02:51:34,713 Building wheel for fastapi-casbin-auth (setup.py): started 2024-11-12T02:51:34,714 Destination directory: /tmp/pip-wheel-el9qr_d3 2024-11-12T02:51:34,715 Running command python setup.py bdist_wheel 2024-11-12T02:51:35,174 # fastapi-casbin-auth 2024-11-12T02:51:35,175 [![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:35,175 [![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:35,176 [![Version](https://img.shields.io/pypi/v/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:35,177 [![PyPI - Wheel](https://img.shields.io/pypi/wheel/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:35,177 [![Pyversions](https://img.shields.io/pypi/pyversions/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:35,178 [![Download](https://img.shields.io/pypi/dm/fastapi-casbin-auth.svg)](https://pypi.org/project/fastapi-casbin-auth/) 2024-11-12T02:51:35,179 [![Discord](https://img.shields.io/discord/1022748306096537660?logo=discord&label=discord&color=5865F2)](https://discord.gg/S5UjpzGZjN) 2024-11-12T02:51:35,180 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:35,181 ## Installation 2024-11-12T02:51:35,183 Install from pip 2024-11-12T02:51:35,185 ```bash 2024-11-12T02:51:35,188 pip install fastapi-casbin-auth 2024-11-12T02:51:35,190 ``` 2024-11-12T02:51:35,192 Clone this repo 2024-11-12T02:51:35,194 ```bash 2024-11-12T02:51:35,195 git clone https://github.com/officialpycasbin/fastapi-casbin-auth.git 2024-11-12T02:51:35,196 python setup.py install 2024-11-12T02:51:35,197 ``` 2024-11-12T02:51:35,199 ## Quickstart 2024-11-12T02:51:35,201 This middleware is designed to work with another middleware which implement `AuthenticationMiddleware` interface. 2024-11-12T02:51:35,203 ```python 2024-11-12T02:51:35,204 import base64 2024-11-12T02:51:35,205 import binascii 2024-11-12T02:51:35,207 import casbin 2024-11-12T02:51:35,209 from fastapi import FastAPI 2024-11-12T02:51:35,210 from starlette.authentication import AuthenticationBackend, AuthenticationError, SimpleUser, AuthCredentials 2024-11-12T02:51:35,211 from starlette.middleware.authentication import AuthenticationMiddleware 2024-11-12T02:51:35,213 from fastapi_casbin_auth import CasbinMiddleware 2024-11-12T02:51:35,215 app = FastAPI() 2024-11-12T02:51:35,218 class BasicAuth(AuthenticationBackend): 2024-11-12T02:51:35,219 async def authenticate(self, request): 2024-11-12T02:51:35,220 if "Authorization" not in request.headers: 2024-11-12T02:51:35,222 return None 2024-11-12T02:51:35,223 auth = request.headers["Authorization"] 2024-11-12T02:51:35,223 try: 2024-11-12T02:51:35,224 scheme, credentials = auth.split() 2024-11-12T02:51:35,225 decoded = base64.b64decode(credentials).decode("ascii") 2024-11-12T02:51:35,225 except (ValueError, UnicodeDecodeError, binascii.Error): 2024-11-12T02:51:35,226 raise AuthenticationError("Invalid basic auth credentials") 2024-11-12T02:51:35,227 username, _, password = decoded.partition(":") 2024-11-12T02:51:35,227 return AuthCredentials(["authenticated"]), SimpleUser(username) 2024-11-12T02:51:35,229 enforcer = casbin.Enforcer('../examples/rbac_model.conf', '../examples/rbac_policy.csv') 2024-11-12T02:51:35,231 app.add_middleware(CasbinMiddleware, enforcer=enforcer) 2024-11-12T02:51:35,231 app.add_middleware(AuthenticationMiddleware, backend=BasicAuth()) 2024-11-12T02:51:35,233 @app.get('/') 2024-11-12T02:51:35,234 async def index(): 2024-11-12T02:51:35,234 return "If you see this, you have been authenticated." 2024-11-12T02:51:35,236 @app.get('/dataset1/protected') 2024-11-12T02:51:35,237 async def auth_test(): 2024-11-12T02:51:35,237 return "You must be alice to see this." 2024-11-12T02:51:35,238 ``` 2024-11-12T02:51:35,239 - anonymous request 2024-11-12T02:51:35,241 ```bash 2024-11-12T02:51:35,241 curl -i http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:35,242 ``` 2024-11-12T02:51:35,243 ```bash 2024-11-12T02:51:35,244 HTTP/1.1 403 Forbidden 2024-11-12T02:51:35,244 date: Mon, 01 Mar 2021 09:00:08 GMT 2024-11-12T02:51:35,245 server: uvicorn 2024-11-12T02:51:35,245 content-length: 11 2024-11-12T02:51:35,246 content-type: application/json 2024-11-12T02:51:35,247 "Forbidden" 2024-11-12T02:51:35,248 ``` 2024-11-12T02:51:35,249 - authenticated request 2024-11-12T02:51:35,251 ```bash 2024-11-12T02:51:35,251 curl -i -u alice:password http://127.0.0.1:8000/dataset1/protected 2024-11-12T02:51:35,252 ``` 2024-11-12T02:51:35,254 ```bash 2024-11-12T02:51:35,254 HTTP/1.1 200 OK 2024-11-12T02:51:35,255 date: Mon, 01 Mar 2021 09:04:54 GMT 2024-11-12T02:51:35,255 server: uvicorn 2024-11-12T02:51:35,256 content-length: 32 2024-11-12T02:51:35,257 content-type: application/json 2024-11-12T02:51:35,258 "You must be alice to see this." 2024-11-12T02:51:35,259 ``` 2024-11-12T02:51:35,260 It used the casbin config from `examples` folder, and you can find this demo in `demo` folder. 2024-11-12T02:51:35,262 You can also view the unit tests to understand this middleware. 2024-11-12T02:51:35,263 Besides, there is another example for `CasbinMiddleware` which is designed to work with JWT authentication. You can find 2024-11-12T02:51:35,264 it in `demo/jwt_test.py`. 2024-11-12T02:51:35,266 ## Development 2024-11-12T02:51:35,266 ### Run unit tests 2024-11-12T02:51:35,267 1. Fork/Clone repository 2024-11-12T02:51:35,268 2. Install fastapi-casbin-auth dependencies, and run `pytest` 2024-11-12T02:51:35,269 ```bash 2024-11-12T02:51:35,269 pip install -r dev_requirements.txt 2024-11-12T02:51:35,270 pip install -r requirements.txt 2024-11-12T02:51:35,270 pytest 2024-11-12T02:51:35,271 ``` 2024-11-12T02:51:35,271 ### Update requirements with pip-tools 2024-11-12T02:51:35,273 ```bash 2024-11-12T02:51:35,273 # update requirements.txt 2024-11-12T02:51:35,274 pip-compile --no-annotate --no-header --rebuild requirements.in 2024-11-12T02:51:35,274 # sync venv 2024-11-12T02:51:35,274 pip-sync 2024-11-12T02:51:35,275 ``` 2024-11-12T02:51:35,276 ### Manually Bump Version 2024-11-12T02:51:35,277 ``` 2024-11-12T02:51:35,277 bumpversion major # major release 2024-11-12T02:51:35,278 or 2024-11-12T02:51:35,278 bumpversion minor # minor release 2024-11-12T02:51:35,279 or 2024-11-12T02:51:35,279 bumpversion patch # hotfix release 2024-11-12T02:51:35,280 ``` 2024-11-12T02:51:35,281 ## Documentation 2024-11-12T02:51:35,282 The authorization determines a request based on ``{subject, object, action}``, which means what ``subject`` can perform 2024-11-12T02:51:35,282 what ``action`` on what ``object``. In this plugin, the meanings are: 2024-11-12T02:51:35,283 1. ``subject``: the logged-in user name 2024-11-12T02:51:35,284 2. ``object``: the URL path for the web resource like `dataset1/item1` 2024-11-12T02:51:35,284 3. ``action``: HTTP method like GET, POST, PUT, DELETE, or the high-level actions you defined like "read-file", " 2024-11-12T02:51:35,285 write-blog" (currently no official support in this middleware) 2024-11-12T02:51:35,286 For how to write authorization policy and other details, please refer 2024-11-12T02:51:35,286 to [the Casbin's documentation](https://casbin.org). 2024-11-12T02:51:35,287 ## Getting Help 2024-11-12T02:51:35,288 - [Casbin](https://casbin.org) 2024-11-12T02:51:35,289 ## License 2024-11-12T02:51:35,290 This project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text. 2024-11-12T02:51:35,785 running bdist_wheel 2024-11-12T02:51:35,933 running build 2024-11-12T02:51:35,934 running build_py 2024-11-12T02:51:35,964 creating build/lib/fastapi_casbin_auth 2024-11-12T02:51:35,967 copying fastapi_casbin_auth/middleware.py -> build/lib/fastapi_casbin_auth 2024-11-12T02:51:35,969 copying fastapi_casbin_auth/__init__.py -> build/lib/fastapi_casbin_auth 2024-11-12T02:51:35,971 running egg_info 2024-11-12T02:51:35,998 writing fastapi_casbin_auth.egg-info/PKG-INFO 2024-11-12T02:51:36,002 writing dependency_links to fastapi_casbin_auth.egg-info/dependency_links.txt 2024-11-12T02:51:36,004 writing requirements to fastapi_casbin_auth.egg-info/requires.txt 2024-11-12T02:51:36,005 writing top-level names to fastapi_casbin_auth.egg-info/top_level.txt 2024-11-12T02:51:36,038 reading manifest file 'fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:36,040 adding license file 'LICENSE' 2024-11-12T02:51:36,043 writing manifest file 'fastapi_casbin_auth.egg-info/SOURCES.txt' 2024-11-12T02:51:36,072 /usr/local/lib/python3.11/dist-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. 2024-11-12T02:51:36,073 !! 2024-11-12T02:51:36,074 ******************************************************************************** 2024-11-12T02:51:36,074 Please avoid running ``setup.py`` directly. 2024-11-12T02:51:36,075 Instead, use pypa/build, pypa/installer or other 2024-11-12T02:51:36,076 standards-based tools. 2024-11-12T02:51:36,077 See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. 2024-11-12T02:51:36,078 ******************************************************************************** 2024-11-12T02:51:36,079 !! 2024-11-12T02:51:36,080 self.initialize_options() 2024-11-12T02:51:36,101 installing to build/bdist.linux-armv7l/wheel 2024-11-12T02:51:36,102 running install 2024-11-12T02:51:36,126 running install_lib 2024-11-12T02:51:36,153 creating build/bdist.linux-armv7l/wheel 2024-11-12T02:51:36,155 creating build/bdist.linux-armv7l/wheel/fastapi_casbin_auth 2024-11-12T02:51:36,157 copying build/lib/fastapi_casbin_auth/middleware.py -> build/bdist.linux-armv7l/wheel/./fastapi_casbin_auth 2024-11-12T02:51:36,159 copying build/lib/fastapi_casbin_auth/__init__.py -> build/bdist.linux-armv7l/wheel/./fastapi_casbin_auth 2024-11-12T02:51:36,160 running install_data 2024-11-12T02:51:36,187 creating build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.1.0.data/data 2024-11-12T02:51:36,189 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.1.0.data/data' 2024-11-12T02:51:36,190 copying README.md -> build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.1.0.data/data 2024-11-12T02:51:36,191 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.1.0.data/data' 2024-11-12T02:51:36,192 copying requirements.txt -> build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.1.0.data/data 2024-11-12T02:51:36,193 running install_egg_info 2024-11-12T02:51:36,227 Copying fastapi_casbin_auth.egg-info to build/bdist.linux-armv7l/wheel/./fastapi_casbin_auth-1.1.0-py3.11.egg-info 2024-11-12T02:51:36,237 running install_scripts 2024-11-12T02:51:36,251 creating build/bdist.linux-armv7l/wheel/fastapi_casbin_auth-1.1.0.dist-info/WHEEL 2024-11-12T02:51:36,253 creating '/tmp/pip-wheel-el9qr_d3/fastapi_casbin_auth-1.1.0-py3-none-any.whl' and adding 'build/bdist.linux-armv7l/wheel' to it 2024-11-12T02:51:36,255 adding 'fastapi_casbin_auth/__init__.py' 2024-11-12T02:51:36,256 adding 'fastapi_casbin_auth/middleware.py' 2024-11-12T02:51:36,259 adding 'fastapi_casbin_auth-1.1.0.data/data/README.md' 2024-11-12T02:51:36,260 adding 'fastapi_casbin_auth-1.1.0.data/data/requirements.txt' 2024-11-12T02:51:36,263 adding 'fastapi_casbin_auth-1.1.0.dist-info/LICENSE' 2024-11-12T02:51:36,265 adding 'fastapi_casbin_auth-1.1.0.dist-info/METADATA' 2024-11-12T02:51:36,266 adding 'fastapi_casbin_auth-1.1.0.dist-info/WHEEL' 2024-11-12T02:51:36,267 adding 'fastapi_casbin_auth-1.1.0.dist-info/top_level.txt' 2024-11-12T02:51:36,268 adding 'fastapi_casbin_auth-1.1.0.dist-info/RECORD' 2024-11-12T02:51:36,269 removing build/bdist.linux-armv7l/wheel 2024-11-12T02:51:36,382 Building wheel for fastapi-casbin-auth (setup.py): finished with status 'done' 2024-11-12T02:51:36,385 Created wheel for fastapi-casbin-auth: filename=fastapi_casbin_auth-1.1.0-py3-none-any.whl size=10941 sha256=5589ec1ca54d6811cdff7b77483fbf79ced20a1f926b0fcdd3e7d70ee2656971 2024-11-12T02:51:36,387 Stored in directory: /tmp/pip-ephem-wheel-cache-frnkfqhg/wheels/d3/a4/b4/8238b1233ab91bad7192beac14ac5d02c7e0b60d22152c0f49 2024-11-12T02:51:36,397 Successfully built fastapi-casbin-auth 2024-11-12T02:51:36,401 Removed build tracker: '/tmp/pip-build-tracker-y1qdqx25'