Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
flask-encrypted-cookies-session
Advanced tools
A cookie based session for flask
relying on Fernet
encrypted cookies.
flask
default session rely on signed cookies. This sometimes is not enough, and encrypted data should be used.
Example : Use cookies to store OAuth2 access tokens without the burden of server side storage.
pip install flask-encrypted-cookies-session
Private key used to encrypt cookies can be generated with python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key())"
# -*- coding: utf-8 -*-
from flask import Flask, session
from flask_encrypted_cookies_session import EncryptedCookieSession
DEBUG = "True"
ENCRYPTED_COOKIES_SECRET_KEY = (
"JNJQuYdaUGr8XBSoZNYF9FC-A7RZ7iFqV_KqrCwYr0s=" # Fernet.generate_key()
)
# To rotate your keys:
# ENCRYPTED_COOKIES_SECRET_KEY = "JNJQuYdaUGr8XBSoZNYF9FC-A7RZ7iFqV_KqrCwYr0s=,Dfo2hCeG-S6CeY-_tgJ33gip9rxC2t8qNK0CM0gZlRk=" # [Fernet.generate_key(), Fernet.generate_key()]
app = Flask(__name__)
app.config.from_object(__name__)
# This will replace the default Flask application session interface with the encrypted
# cookie based session
EncryptedCookieSession(app)
@app.route("/set/")
def session_set():
session["key"] = "value"
return "ok"
@app.route("/get/")
def session_get():
return session.get("key", "not set")
poetry
is used to manage this project.
poe the poet
is used as the task runner of this project. If you don't know what a task runner is, think about an alternative version of a Makefile
.
$ poetry install
$ poe test
$ poe test-py39
The github repository should be used for Issues or contributions.
FAQs
An encrypted cookie based session implementation for flask
We found that flask-encrypted-cookies-session demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.