yhttp-auth
Authentication extension for yhttp.
Install
pip install yhttp-auth
Usage
from yhttp import Application
from yhttp.ext.auth import install as auth_install
app = Application('0.1.0', 'foo')
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
Contribution
python-makelib
Install python-makelib.
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-11.1.1.tar.gz
(11.2 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
File details
Details for the file yhttp_auth-11.1.1.tar.gz.
File metadata
- Download URL: yhttp_auth-11.1.1.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
593f28070083f32c6b1084e66d69420afb855d34507b37798b98f559ca796776
|
|
| MD5 |
7bceb9a7633be0863b32109086d0a63d
|
|
| BLAKE2b-256 |
e10568385e4da6a496eeb30f7b006acd5cef77efc5a8fdf56dab604a999d136a
|
File details
Details for the file yhttp_auth-11.1.1-py3-none-any.whl.
File metadata
- Download URL: yhttp_auth-11.1.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdf31430910c4e805a4ef6f8b099485b13d3aee996276094fcb8344271196650
|
|
| MD5 |
50fe4c9ebaf5f6ae78310568023dfd8a
|
|
| BLAKE2b-256 |
e8d846b450f65e3818b00a8f7bd1821d0a1eba27fbe1997abe1f8d2173f6a4a7
|