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-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


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

Uploaded Source

Built Distribution

yhttp_auth-6.0.0-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yhttp_auth-6.0.0.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for yhttp_auth-6.0.0.tar.gz
Algorithm Hash digest
SHA256 9194d01b932cffeff81d96f4ac0fdc7944a992c8eecfe1b19624a3ffeea575bd
MD5 304a45ec95bee5fd836eab695ac5d142
BLAKE2b-256 b6198fdeeebc67e2ed8747338145877f8743b7e156995063ad1d31aba4c1cd9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yhttp_auth-6.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for yhttp_auth-6.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f00a84be5e333c7cdeefc57e38f87c3f1e411f91c61a65e85d23fe4b866a0f41
MD5 689d31639b01ecdc9102035c1c21b3d3
BLAKE2b-256 489ea567e4e9a536f1149fd2a588a4808bd653cbb1364b1902c2bfdaadc4d1a5

See more details on using hashes here.

Supported by

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