A very micro http framework.
Project description
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.
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-8.0.0.tar.gz
(10.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
File details
Details for the file yhttp_auth-8.0.0.tar.gz.
File metadata
- Download URL: yhttp_auth-8.0.0.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b7ee71bb358ad2644cf024cecd62647cfc77af14f8fd14182dc272fd9235fd1c
|
|
| MD5 |
38128b7f65d67f3bcb1bb188b4319ad4
|
|
| BLAKE2b-256 |
1e1ff69e2966157149f2f0c6b6f00a43363a59a3f46370c1e44763aeb8448dac
|
File details
Details for the file yhttp_auth-8.0.0-py3-none-any.whl.
File metadata
- Download URL: yhttp_auth-8.0.0-py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28c41c22894af7496f348f307e5f4a1d576090616953c97536733095b555b72f
|
|
| MD5 |
6f7b2e742694657c0f6f5e2fb638ee96
|
|
| BLAKE2b-256 |
3a2fd65bcd08f5e6dd96260a92b8b09ead590095d53c9782facd6487137877a2
|