%global _empty_manifest_terminate_build 0 Name: python-aiohttp-jwt Version: 0.6.1 Release: 1 Summary: aiohttp middleware for working with JWT License: MIT URL: https://github.com/hzlmn/aiohttp-jwt Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e7/2f/1f17fb96577b6ff038034949df7ddcaf740c0780f1e699a157f0e387534e/aiohttp_jwt-0.6.1.tar.gz BuildArch: noarch Requires: python3-aiohttp Requires: python3-PyJWT %description ## aiohttp-jwt [![Downloads](https://pepy.tech/badge/aiohttp-jwt/month)](https://pepy.tech/project/aiohttp-jwt/month) [![Build Status](https://travis-ci.org/hzlmn/aiohttp-jwt.svg?branch=master)](https://travis-ci.org/hzlmn/aiohttp-jwt) [![codecov](https://codecov.io/gh/hzlmn/aiohttp-jwt/branch/master/graph/badge.svg)](https://codecov.io/gh/hzlmn/aiohttp-jwt) The library provides `aiohttp` middleware and helper utils for working with JSON web tokens. * Works on Python3.5+ * MIT License * Latest docs [TBD]() * Contributions are highly welcome! ## Requirements - [Aiohttp >= 2.3.5](https://github.com/aio-libs/aiohttp) - [PyJWT](https://github.com/jpadilla/pyjwt) ## Install ```bash $ pip install aiohttp_jwt ``` ## Simple Usage `server.py` ```python import jwt from aiohttp import web from aiohttp_jwt import JWTMiddleware sharable_secret = 'secret' async def protected_handler(request): return web.json_response({'user': request['payload']}) app = web.Application( middlewares=[ JWTMiddleware(sharable_secret), ] ) app.router.add_get('/protected', protected_handler) if __name__ == '__main__': web.run_app(app) ``` `client.py` ```python import asyncio import aiohttp import async_timeout async def fetch(session, url, headers=None): async with async_timeout.timeout(10): async with session.get(url, headers=headers) as response: return await response.json() async def main(): async with aiohttp.ClientSession() as session: response = await fetch( session, 'http://localhost:8080/protected', headers={'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3QifQ.pyNsXX_vNsUvdt6xu13F1Gs1zGELT4Va8a38eG5svBA'}) print(response) loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` ## Examples - [Basic Example](/example/basic.py) - [Permissions control](/example/permissions.py) ## Credits This module inspired by official [auth0/express-jwt](https://github.com/auth0/express-jwt) middleware and [express-jwt-permissions](https://github.com/MichielDeMey/express-jwt-permissions) extension. ## Related packages For advanced security facilities check [aio-libs/aiohttp_security](https://github.com/aio-libs/aiohttp-security) ### License MIT License %package -n python3-aiohttp-jwt Summary: aiohttp middleware for working with JWT Provides: python-aiohttp-jwt BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-aiohttp-jwt ## aiohttp-jwt [![Downloads](https://pepy.tech/badge/aiohttp-jwt/month)](https://pepy.tech/project/aiohttp-jwt/month) [![Build Status](https://travis-ci.org/hzlmn/aiohttp-jwt.svg?branch=master)](https://travis-ci.org/hzlmn/aiohttp-jwt) [![codecov](https://codecov.io/gh/hzlmn/aiohttp-jwt/branch/master/graph/badge.svg)](https://codecov.io/gh/hzlmn/aiohttp-jwt) The library provides `aiohttp` middleware and helper utils for working with JSON web tokens. * Works on Python3.5+ * MIT License * Latest docs [TBD]() * Contributions are highly welcome! ## Requirements - [Aiohttp >= 2.3.5](https://github.com/aio-libs/aiohttp) - [PyJWT](https://github.com/jpadilla/pyjwt) ## Install ```bash $ pip install aiohttp_jwt ``` ## Simple Usage `server.py` ```python import jwt from aiohttp import web from aiohttp_jwt import JWTMiddleware sharable_secret = 'secret' async def protected_handler(request): return web.json_response({'user': request['payload']}) app = web.Application( middlewares=[ JWTMiddleware(sharable_secret), ] ) app.router.add_get('/protected', protected_handler) if __name__ == '__main__': web.run_app(app) ``` `client.py` ```python import asyncio import aiohttp import async_timeout async def fetch(session, url, headers=None): async with async_timeout.timeout(10): async with session.get(url, headers=headers) as response: return await response.json() async def main(): async with aiohttp.ClientSession() as session: response = await fetch( session, 'http://localhost:8080/protected', headers={'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3QifQ.pyNsXX_vNsUvdt6xu13F1Gs1zGELT4Va8a38eG5svBA'}) print(response) loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` ## Examples - [Basic Example](/example/basic.py) - [Permissions control](/example/permissions.py) ## Credits This module inspired by official [auth0/express-jwt](https://github.com/auth0/express-jwt) middleware and [express-jwt-permissions](https://github.com/MichielDeMey/express-jwt-permissions) extension. ## Related packages For advanced security facilities check [aio-libs/aiohttp_security](https://github.com/aio-libs/aiohttp-security) ### License MIT License %package help Summary: Development documents and examples for aiohttp-jwt Provides: python3-aiohttp-jwt-doc %description help ## aiohttp-jwt [![Downloads](https://pepy.tech/badge/aiohttp-jwt/month)](https://pepy.tech/project/aiohttp-jwt/month) [![Build Status](https://travis-ci.org/hzlmn/aiohttp-jwt.svg?branch=master)](https://travis-ci.org/hzlmn/aiohttp-jwt) [![codecov](https://codecov.io/gh/hzlmn/aiohttp-jwt/branch/master/graph/badge.svg)](https://codecov.io/gh/hzlmn/aiohttp-jwt) The library provides `aiohttp` middleware and helper utils for working with JSON web tokens. * Works on Python3.5+ * MIT License * Latest docs [TBD]() * Contributions are highly welcome! ## Requirements - [Aiohttp >= 2.3.5](https://github.com/aio-libs/aiohttp) - [PyJWT](https://github.com/jpadilla/pyjwt) ## Install ```bash $ pip install aiohttp_jwt ``` ## Simple Usage `server.py` ```python import jwt from aiohttp import web from aiohttp_jwt import JWTMiddleware sharable_secret = 'secret' async def protected_handler(request): return web.json_response({'user': request['payload']}) app = web.Application( middlewares=[ JWTMiddleware(sharable_secret), ] ) app.router.add_get('/protected', protected_handler) if __name__ == '__main__': web.run_app(app) ``` `client.py` ```python import asyncio import aiohttp import async_timeout async def fetch(session, url, headers=None): async with async_timeout.timeout(10): async with session.get(url, headers=headers) as response: return await response.json() async def main(): async with aiohttp.ClientSession() as session: response = await fetch( session, 'http://localhost:8080/protected', headers={'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3QifQ.pyNsXX_vNsUvdt6xu13F1Gs1zGELT4Va8a38eG5svBA'}) print(response) loop = asyncio.get_event_loop() loop.run_until_complete(main()) ``` ## Examples - [Basic Example](/example/basic.py) - [Permissions control](/example/permissions.py) ## Credits This module inspired by official [auth0/express-jwt](https://github.com/auth0/express-jwt) middleware and [express-jwt-permissions](https://github.com/MichielDeMey/express-jwt-permissions) extension. ## Related packages For advanced security facilities check [aio-libs/aiohttp_security](https://github.com/aio-libs/aiohttp-security) ### License MIT License %prep %autosetup -n aiohttp-jwt-0.6.1 %build %py3_build %install %py3_install install -d -m755 %{buildroot}/%{_pkgdocdir} if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} if [ -d usr/lib ]; then find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/lib64 ]; then find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/bin ]; then find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst fi if [ -d usr/sbin ]; then find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst fi touch doclist.lst if [ -d usr/share/man ]; then find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/filelist.lst . mv %{buildroot}/doclist.lst . %files -n python3-aiohttp-jwt -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 0.6.1-1 - Package Spec generated