Skip to main content

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.

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-12.0.0.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-12.0.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yhttp_auth-12.0.0.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

Hashes for yhttp_auth-12.0.0.tar.gz
Algorithm Hash digest
SHA256 c9b532d15fd21fc5464e0e8070f2666b754018ac59cbaf16fc7d0977a22fcb3e
MD5 0cff5b749176cbaffc1e2e045d2cc9ef
BLAKE2b-256 70a3d5956808d1e1fe26c5e95ae6f7bf3a8b3cecdb8743a6eda86bf434874289

See more details on using hashes here.

File details

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

File metadata

  • Download URL: yhttp_auth-12.0.0-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

Hashes for yhttp_auth-12.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 30e04f4a8d08bdb49b67c1d3fc51fd27315aa1d28ef107572c88fb1c8cab0aaf
MD5 6f7a65b4ffc554f8bb50601d8e928322
BLAKE2b-256 b4ea25072be136b28f278fbfc4b5346f088f69238fca653f58bab20c01cc95f4

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

12.0.0 This release

2 files

11.1.1

2 files

11.1.0

2 files

11.0.0

2 files

10.4.0

2 files

10.3.0

2 files

10.2.0

2 files

10.0.0

2 files

9.3.2

2 files

9.3.1

2 files

9.3.0

2 files

9.2.1

2 files

9.1.0

2 files

9.0.0

2 files

8.0.0

2 files

7.2.0

2 files

7.1.0

2 files

7.0.1

2 files

7.0.0

2 files

6.0.0

2 files

5.0.2

2 files

5.0.1

2 files

5.0.0

2 files

4.0.0

2 files

3.9.3

2 files

3.9.2

2 files

3.8.1

2 files

3.8.0

2 files

3.7.2

2 files

3.7.0

2 files

3.6.0

2 files

3.5.0

2 files

3.4.5

2 files

3.4.4

2 files

3.4.3

2 files

3.4.2

2 files

3.4.1

2 files

3.1.2

2 files

3.1.1

2 files

3.0.0

2 files

2.0.6

2 files

2.0.5

2 files

2.0.0

2 files

1.2.1

2 files

1.2.0

2 files

1.1.1

1 file

1.1.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page