%global _empty_manifest_terminate_build 0 Name: python-aiohttp-basicauth Version: 1.0.0 Release: 1 Summary: HTTP basic authentication middleware for aiohttp 3.0+ License: Apache 2 URL: https://github.com/romis2012/aiohttp-basicauth Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e0/98/3c164b1b29ad3d32f6824482a9dfd655f177e274012a4abf3078674e300b/aiohttp_basicauth-1.0.0.tar.gz BuildArch: noarch Requires: python3-aiohttp %description ## aiohttp-basicauth [![Build Status](https://api.travis-ci.com/romis2012/aiohttp-basicauth.svg?branch=master)](https://travis-ci.com/github/romis2012/aiohttp-basicauth) [![Coverage Status](https://coveralls.io/repos/github/romis2012/aiohttp-basicauth/badge.svg?branch=master)](https://coveralls.io/github/romis2012/aiohttp-basicauth?branch=master) [![PyPI version](https://badge.fury.io/py/aiohttp-basicauth.svg?_=a)](https://badge.fury.io/py/aiohttp-basicauth) HTTP basic authentication middleware for aiohttp 3.0+. Inspired by [Flask-BasicAuth](https://github.com/jpvanhal/flask-basicauth). ## Requirements - Python >= 3.5.3 - aiohttp >= 3.0 ## Installation ``` pip install aiohttp_basicauth ``` ## Simple usage ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware auth = BasicAuthMiddleware(username='user', password='password') app = web.Application(middlewares=[auth]) web.run_app(app, host='127.0.0.1', port=80) ``` ## Protect specific view(s) ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware auth = BasicAuthMiddleware(username='user', password='password', force=False) async def public_view(request): return web.Response(text='Public view') @auth.required async def secret_view(request): return web.Response(text='Secret view') app = web.Application(middlewares=[auth]) app.router.add_route('GET', '/public', public_view) app.router.add_route('GET', '/secret', secret_view) web.run_app(app, host='127.0.0.1', port=80) ``` ## Advanced usage You can override ```check_credentials``` method to implement more complex user verification logic: ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware class CustomBasicAuth(BasicAuthMiddleware): async def check_credentials(self, username, password, request): # here, for example, you can search user in the database by passed `username` and `password`, etc. return username == 'user' and password == 'password' auth = CustomBasicAuth() app = web.Application(middlewares=[auth]) web.run_app(app, host='127.0.0.1', port=80) ``` %package -n python3-aiohttp-basicauth Summary: HTTP basic authentication middleware for aiohttp 3.0+ Provides: python-aiohttp-basicauth BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip %description -n python3-aiohttp-basicauth ## aiohttp-basicauth [![Build Status](https://api.travis-ci.com/romis2012/aiohttp-basicauth.svg?branch=master)](https://travis-ci.com/github/romis2012/aiohttp-basicauth) [![Coverage Status](https://coveralls.io/repos/github/romis2012/aiohttp-basicauth/badge.svg?branch=master)](https://coveralls.io/github/romis2012/aiohttp-basicauth?branch=master) [![PyPI version](https://badge.fury.io/py/aiohttp-basicauth.svg?_=a)](https://badge.fury.io/py/aiohttp-basicauth) HTTP basic authentication middleware for aiohttp 3.0+. Inspired by [Flask-BasicAuth](https://github.com/jpvanhal/flask-basicauth). ## Requirements - Python >= 3.5.3 - aiohttp >= 3.0 ## Installation ``` pip install aiohttp_basicauth ``` ## Simple usage ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware auth = BasicAuthMiddleware(username='user', password='password') app = web.Application(middlewares=[auth]) web.run_app(app, host='127.0.0.1', port=80) ``` ## Protect specific view(s) ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware auth = BasicAuthMiddleware(username='user', password='password', force=False) async def public_view(request): return web.Response(text='Public view') @auth.required async def secret_view(request): return web.Response(text='Secret view') app = web.Application(middlewares=[auth]) app.router.add_route('GET', '/public', public_view) app.router.add_route('GET', '/secret', secret_view) web.run_app(app, host='127.0.0.1', port=80) ``` ## Advanced usage You can override ```check_credentials``` method to implement more complex user verification logic: ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware class CustomBasicAuth(BasicAuthMiddleware): async def check_credentials(self, username, password, request): # here, for example, you can search user in the database by passed `username` and `password`, etc. return username == 'user' and password == 'password' auth = CustomBasicAuth() app = web.Application(middlewares=[auth]) web.run_app(app, host='127.0.0.1', port=80) ``` %package help Summary: Development documents and examples for aiohttp-basicauth Provides: python3-aiohttp-basicauth-doc %description help ## aiohttp-basicauth [![Build Status](https://api.travis-ci.com/romis2012/aiohttp-basicauth.svg?branch=master)](https://travis-ci.com/github/romis2012/aiohttp-basicauth) [![Coverage Status](https://coveralls.io/repos/github/romis2012/aiohttp-basicauth/badge.svg?branch=master)](https://coveralls.io/github/romis2012/aiohttp-basicauth?branch=master) [![PyPI version](https://badge.fury.io/py/aiohttp-basicauth.svg?_=a)](https://badge.fury.io/py/aiohttp-basicauth) HTTP basic authentication middleware for aiohttp 3.0+. Inspired by [Flask-BasicAuth](https://github.com/jpvanhal/flask-basicauth). ## Requirements - Python >= 3.5.3 - aiohttp >= 3.0 ## Installation ``` pip install aiohttp_basicauth ``` ## Simple usage ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware auth = BasicAuthMiddleware(username='user', password='password') app = web.Application(middlewares=[auth]) web.run_app(app, host='127.0.0.1', port=80) ``` ## Protect specific view(s) ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware auth = BasicAuthMiddleware(username='user', password='password', force=False) async def public_view(request): return web.Response(text='Public view') @auth.required async def secret_view(request): return web.Response(text='Secret view') app = web.Application(middlewares=[auth]) app.router.add_route('GET', '/public', public_view) app.router.add_route('GET', '/secret', secret_view) web.run_app(app, host='127.0.0.1', port=80) ``` ## Advanced usage You can override ```check_credentials``` method to implement more complex user verification logic: ```python from aiohttp import web from aiohttp_basicauth import BasicAuthMiddleware class CustomBasicAuth(BasicAuthMiddleware): async def check_credentials(self, username, password, request): # here, for example, you can search user in the database by passed `username` and `password`, etc. return username == 'user' and password == 'password' auth = CustomBasicAuth() app = web.Application(middlewares=[auth]) web.run_app(app, host='127.0.0.1', port=80) ``` %prep %autosetup -n aiohttp-basicauth-1.0.0 %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-basicauth -f filelist.lst %dir %{python3_sitelib}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 1.0.0-1 - Package Spec generated