A very micro http framework.
Project description
yhttp-auth
Authentication extension for yhttp.
Install
pip install yhttp-pony
Usage
from yhttp import Application
from yhttp.ext.auth import install as auth_install
app = Application()
auth = auth_install(app)
app.settings.merge(f'''
auth:
redis:
host: localhost
port: 6379
db: 0
token:
algorithm: HS256
secret: foobar
refresh:
key: yhttp-refresh-token
algorithm: HS256
secret: quxquux
secure: true
httponly: true
maxage: 2592000 # 1 Month
domain: example.com
''')
@app.route('/reftokens')
@yhttp.statuscode(yhttp.statuses.created)
def create(req):
app.auth.set_refreshtoken(req, 'alice', dict(baz='qux'))
@app.route('/tokens')
@yhttp.statuscode(yhttp.statuses.created)
@yhttp.text
def refresh(req):
reftoken = app.auth.verify_refreshtoken(req)
return app.auth.dump_from_refreshtoken(reftoken, dict(foo='bar'))
@app.route('/admin')
@auth(roles='admin, god')
@yhttp.text
def get(req):
return req.identity.roles
app.ready()
Command line interface
setup.py
setup(
...
entry_points={
'console_scripts': [
'myapp = myapp:app.climain'
]
},
...
)
myapp auth --help
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yhttp-auth-3.4.2.tar.gz
(6.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
yhttp_auth-3.4.2-py3.8.egg
(11.4 kB
view details)
File details
Details for the file yhttp-auth-3.4.2.tar.gz.
File metadata
- Download URL: yhttp-auth-3.4.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5af3f7d38be5e82b8c0cbfea6a42b401dc5ff1d46e31e9bde4b55d058b350fef
|
|
| MD5 |
bc8ae16e9a9fef702d60b562bd3ab606
|
|
| BLAKE2b-256 |
4ac0c5a789821f77cacd20290e1246d559541c178649e837159f9302afbb32f2
|
File details
Details for the file yhttp_auth-3.4.2-py3.8.egg.
File metadata
- Download URL: yhttp_auth-3.4.2-py3.8.egg
- Upload date:
- Size: 11.4 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e75ec8acaf5250b03a411a50a984db6a57d14138547643aef0200dc069abb67f
|
|
| MD5 |
c07ba1343ca71781d1c6751faa6c0e12
|
|
| BLAKE2b-256 |
1e1f49e83f75ecefde737d69c1ec065e7d38aedefb1fd68f7715c84ea91bc5a7
|