Paseto integration for flask
Project description
FLASK-PASETO
flask_paseto add basic supports to your flask app version2 support for paseto
Installation
Install with pip
pip install flask_paseto
Example usage
from flask_paseto import (
Paseto,
paseto_required,
create_access_token,
create_access_token_public,
get_paseto_claim,
get_paseto_claim_public
)
app = Flask(__name__)
app.config['PASETO_SECRET_KEY'] = '0'*32 # must be 32 byte
pk, sk = pysodium.crypto_sign_keypair()
app.config['PASETO_PRIVATE_KEY']=sk
app.config['PASETO_PUBLIC_KEY']=pk
paseto = Paseto(app)
@app.route('/protected/local/')
@paseto_required
def protected():
claims = get_paseto_claim()
return jsonify(claims), 200
@app.route('/create/local/token/')
def create_token():
ret = {'access_token': create_access_token({'test user':'yes'})}
return jsonify(ret), 200
@app.route('/create/public/token/')
def create_public_token():
ret = {'access_token': create_access_token_public({'public test user':'yes'})}
return jsonify(ret), 200
@app.route('/protected/public/')
@paseto_required
def protected_public():
claims = get_paseto_claim_public()
return jsonify(claims), 200
app.run()
The client http request must provide a generated paseto token
GET /protected/public HTTP/1.1
Authorization: Bearer v2.local.epxJJp-rchdlMondp12dxN9MV7GACjW0swwyOgo5pliQo2fJmC-1WqhrmWDTQBkg08In7zXD6ieM-xpaY2eMWr-mAu64nVi8VvTWi5bc3dhGHGR-Mg8QQ8HJIzPldLfSDLQXwQ
Configuration Options
Option | Description |
---|---|
PASETO_SECRET_KEY | This is the secret key used by paseto to sign your data. It requires 32 byte strings |
PASETO_PUBLIC_KEY | This is the public key generated as part of the key pair generated for paseto |
PASETO_PRIVATE_KEY | This is the private key generated as part of the key pair generated for paseto |
PASETO_EXPIRATION_DELTA | The additional time from the current time the token was created before expiration |
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
Flask-PASETO-0.0.1.tar.gz
(4.2 kB
view details)
Built Distribution
File details
Details for the file Flask-PASETO-0.0.1.tar.gz
.
File metadata
- Download URL: Flask-PASETO-0.0.1.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c939dd7e588f48acf8f1a2987ed9d731bd7e75415f63b939fcb2b159bc77c426 |
|
MD5 | d9d9b7a6382f2ba955cf10401a0f18e5 |
|
BLAKE2b-256 | d73180e98d63a264399cbda5e44a03461eca94305290c4ab021bce41032c5341 |
File details
Details for the file Flask_PASETO-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: Flask_PASETO-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 050d4ce8d51775a0a86fd249a9de2d2224f52d826473c6dbc3ffa1881bb28b2f |
|
MD5 | 90e5f88793856ff23761fad99b6588f8 |
|
BLAKE2b-256 | f1a7a302b72c29eaf43635d2d7f8663350de3c9f33a72283fa8071a150abd584 |