JWT plugin for bottle
Project description
JWT plugin for bottle
installation
Via pip: pip install bottlejwt
Or clone: git clone https://github.com/kianxineki/bottlejwt.git
example server:
from bottle import get, install, run
from bottlejwt import JwtPlugin
def validation(auth, auth_value):
print(auth, auth_value)
return True
@get("/", auth="any values and types")
def example(auth): # auth argument is optional!
return "ok"
install(JwtPlugin(validation, 'secret', algorithm='HS256'))
run(host="0.0.0.0", port="9988")
Test:
curl http://localhost:9988/?access_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWV9.TJVA95OrM7E2cBab30RMHrHDcEfxjoYZgeFONFh7HgQ
Create Token:
from bottlejwt import JwtPlugin
# is a singleton, you only need to initialize once.
# * If you did install () also work
JwtPlugin(validation, 'secret', algorithm='HS256')
print(JwtPlugin.encode({'name': 'pepito'}))
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
bottlejwt-0.0.6.tar.gz
(2.8 kB
view details)
File details
Details for the file bottlejwt-0.0.6.tar.gz.
File metadata
- Download URL: bottlejwt-0.0.6.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7922d98a2e1c8ab765700cb4f27cd4d51664341577360ce32182961513a4bc83
|
|
| MD5 |
1e737eab4acd5815c73084412f5156d2
|
|
| BLAKE2b-256 |
d5e46cd78d4fb1f40350aadb7446feee7b34f3f69beab26a4c4ef1d80583da0b
|