Skip to main content

No project description provided

Project description

A new signed-cookie implementation for Beaker Sessions

Features

  • so much safer than default Pickle serialization
  • serialize with BSON and compress, so more datatypes supported than JSON (optional)
  • multiple keys, so you can rotate them
  • stronger hash algorithm (SHA256)
  • backwards compatible reads/writes with original pickle-based beaker session cookies
  • JWT for signing (although not much else of JWT is implemented)

Install

pip install 'beaker-session-jwt'

Usage

See beaker docs for general implementation. Specify using this class:

from beaker_session_jwt import JWTCookieSession

app = SessionMiddleware(app, config, session_class=JWTCookieSession)

Additional config options

See Beaker docs for main config options, many of which apply to this class too.

  • jwt_secret_keys required. One or more comma-separated keys
    • generate a key with python -c 'import secrets; print(secrets.token_hex());'
    • multiple signing keys are supported, so you can rotate them. The first one in the list will be used for writing, the rest will be permitted for verifying.
  • bson_compress_jwt_payload default True
    • serializing with BSON and compressing with zlib, to allow for types like datetime, bytes, etc to be stored which JSON cannot store. This is stored all in a single JWT field, so JWT is hardly being used, just for signatures really
  • read_original_format default False
    • set to true to read original beaker signed cookies. Allows for backward compatibility and transition periods
    • after a transition period, make sure to set this back to False
  • original_format_validate_key required if read_original_format
  • original_format_data_serializer
  • original_format_remove_keys optional comma-separated list
    • if your old sessions have values that pickle supported, but don't work any more, list the session keys here. They will be removed but the rest of the session will be preserved.
  • write_original_format default False
    • set to true if you have many servers/processes and need to roll this out gradually. Then later set to False when all processes are ready.

Non-Features

  • no encrypted cookies (could be possible with JWT though)
  • JWT payload/claim fields (iss, sub, exp, etc) are not used or verified. Instead, this uses the fields that a beaker CookieSession has, for maximum backwards compatibility and simplicity.
  • pymongo/bson is always required even with bson_compress_jwt_payload=False

License

Apache License

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

beaker_session_jwt-1.0.3.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

beaker_session_jwt-1.0.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file beaker_session_jwt-1.0.3.tar.gz.

File metadata

  • Download URL: beaker_session_jwt-1.0.3.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.11

File hashes

Hashes for beaker_session_jwt-1.0.3.tar.gz
Algorithm Hash digest
SHA256 edc76d9e54d39cc5ce93c4996a1077de13f0c06abcc6c2f516c62f143b97e519
MD5 25c5d63b3ffa334dd15b397ea2d1279b
BLAKE2b-256 1781363fe4a84be99e7126d2de549c2c31e0c573db921d69f424d2c2c96e5754

See more details on using hashes here.

File details

Details for the file beaker_session_jwt-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for beaker_session_jwt-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6208f630cd69988e790e193f1c77630aeabf4f900b87746631a81ef6befcdb04
MD5 3b91c4fc4a95dc03b14fe7d45ec12cca
BLAKE2b-256 99caa0aba9b81f8a0dea855aec426648dc2f7988e1ed5389addced853486adbe

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