Skip to main content

A very micro http framework.

Project description

yhttp-auth

PyPI Build Coverage Status

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


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-9.3.1.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yhttp_auth-9.3.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file yhttp_auth-9.3.1.tar.gz.

File metadata

  • Download URL: yhttp_auth-9.3.1.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yhttp_auth-9.3.1.tar.gz
Algorithm Hash digest
SHA256 e45f4720a7ceacc696b65d0749b4f34affa2f5ee8a14343b5625c32ad51c5708
MD5 af17aa4ca3b20721dd5a5ebc74d2de9f
BLAKE2b-256 685f8a9be439c194496d7de6bf09698c11df1966b6583464306eebb13733b3cf

See more details on using hashes here.

File details

Details for the file yhttp_auth-9.3.1-py3-none-any.whl.

File metadata

  • Download URL: yhttp_auth-9.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for yhttp_auth-9.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5b8b547ef18052a1d8a70e8dad682be9d4444d60f98a696488e4091165550a1b
MD5 464c1e347366c05aa968a2ece4e0b6bf
BLAKE2b-256 28d6f6adfff5b5f95a0035e18c6f799963dd9611b1d27f8f01dfe2d01875ddf0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page