Skip to main content

Signed & trusted sessions for falcon.

Project description

Falcon signed sessions

This project allows you to easily add trusted cookies to falcon, it works by storing a signed cookie in the client's browser using itsdangerous what we call a session. If the cookie is edited the data won't be loaded into the session context. If you don't store the secret key & salt somewhere secure (like a env file) then the session data will be invalidated between restarts.

How it works

  • Use req.context.get_session(key) to read session data, None if doesn't exist.
  • Use req.context.sessions() to read all sessions.
  • Use resp.context.set_session(key, value) to edit session data & sign for client.

How to use

import secrets
from FalconSignedSessions import SignedSessions


app = falcon.App()
app.add_middleware(
    SignedSessions(
        secret_key=secrets.token_urlsafe(24),
        salt=secrets.token_bytes(),
        session_cookie="session"
    )
)


class SessionResource:
    def on_get(self, req: Request, resp: Response) -> None:
        # Get all sessions as dict.
        print(req.context.sessions())

        # Used to get a session
        print(req.context.get_session("trusted"))

        # Set a session.
        resp.context.set_session("trusted", True)


app.add_route("/cookies", SessionResource())

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

FalconSignedSessions-0.0.2.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

FalconSignedSessions-0.0.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file FalconSignedSessions-0.0.2.tar.gz.

File metadata

  • Download URL: FalconSignedSessions-0.0.2.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for FalconSignedSessions-0.0.2.tar.gz
Algorithm Hash digest
SHA256 895beae7b447a4c0b366b0aab2b27dbecfeb7c3f2c33efce53bdb32a748eeddb
MD5 e88d03db5b302f9fbeda159d644d6b6c
BLAKE2b-256 3c0d6e4b6387d68998c29ca324fe222e3a0e23ee6ba8a572a573f4fad1c88461

See more details on using hashes here.

File details

Details for the file FalconSignedSessions-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: FalconSignedSessions-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.10.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for FalconSignedSessions-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eca441834e9130a7e4b15f4309d771ee294445fd28fcfb8221d67373526f4582
MD5 1cb7cb24db54225c6c0054af22d1e57b
BLAKE2b-256 6f99b226ae94a29c032fc59f61f74d693863d61b443203e6e53fea93b6deeb16

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