diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 13:56:56 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 13:56:56 +0000 |
commit | 492b853c00f2adb2b3134339997997643ed06df3 (patch) | |
tree | 29ed2d34ac9627f29b88fb4d9883a7c9a5ab0b42 /python-aiohttp-basicauth.spec | |
parent | 92c877d29a5a9db9bb81134d6c172d442ce275ed (diff) |
automatic import of python-aiohttp-basicauthopeneuler20.03
Diffstat (limited to 'python-aiohttp-basicauth.spec')
-rw-r--r-- | python-aiohttp-basicauth.spec | 307 |
1 files changed, 307 insertions, 0 deletions
diff --git a/python-aiohttp-basicauth.spec b/python-aiohttp-basicauth.spec new file mode 100644 index 0000000..3dd0b1d --- /dev/null +++ b/python-aiohttp-basicauth.spec @@ -0,0 +1,307 @@ +%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 + +[](https://travis-ci.com/github/romis2012/aiohttp-basicauth) +[](https://coveralls.io/github/romis2012/aiohttp-basicauth?branch=master) +[](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 + +[](https://travis-ci.com/github/romis2012/aiohttp-basicauth) +[](https://coveralls.io/github/romis2012/aiohttp-basicauth?branch=master) +[](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 + +[](https://travis-ci.com/github/romis2012/aiohttp-basicauth) +[](https://coveralls.io/github/romis2012/aiohttp-basicauth?branch=master) +[](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 <Python_Bot@openeuler.org> - 1.0.0-1 +- Package Spec generated |