Skip to main content

flask_session_mysql adds server side session manager making applications for flask more secure and efficient in MySQL

Project description

Flask Session MySQL

Flask-session-mysql is a package that enhances the security and usability of Flask sessions by storing them in a MySQL database. This server-side storage ensures that no sensitive data is exposed, prioritizing security.

How it Works

The functioning of this package is straightforward. When a session is generated or data is stored (in cookies), Flask typically stores this information in a base64-encoded format within the browser's session cookies. However, this approach can be both vulnerable and unsafe.

To enhance security, this package generates a unique 64-character UUID (Universally Unique Identifier) code. This ensures that the cookies used for sessions are both secure and resistant to vulnerabilities, significantly improving the overall security of your application and making your life easier.

Flask approach

Flask_approach

Which if you decode

eyJoZWxsbyI6IndvcmxkIn0.ZQxasQ.KgRPUWvqZ57ccAWwd9qzOdAa9dg ---> {"hello":"world"}C@=E{qj@k` (Pretty unsafe)

Flask Session MySQL approach

My_Approach db_table

As you see this is more secure and better for production development feel free to report any issues or suggestions!

INSTALLATION

pip install flask-session-mysql

or with git

git clone https://github.com/Fabioblyk/flask-session-mysql
python setup.py install

How to use it?

from flask import Flask, session
from flask_session_mysql import MysqlSession

app = Flask(__name__)
app.secret_key = 'some_pretty_cool_secret_key_here'
app.config['MYSQL_SESSION_HOST'] = 'localhost'
app.config['MYSQL_SESSION_USERNAME'] = 'root'
app.config['MYSQL_SESSION_PASSWORD'] = ''
app.config['MYSQL_SESSION_DATABASE'] = 'test'

MysqlSession(app)


@app.route('/example')
def example():
    session['hello'] = 'world'
    return "Hello World"


app.run(port=5555)

NOTE: Make sure you config the mysql data before binding it or it won't work First configuration then binding!

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_session_mysql-0.0.2.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

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

flask_session_mysql-0.0.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_session_mysql-0.0.2.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for flask_session_mysql-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2f0e9344be5e2ad0da583cd06ff35aa4f1f281400c48cccff8fdc34ad618e6c2
MD5 60feaf669029bb36e2d2450b4a598527
BLAKE2b-256 63d502b6226d3cc1d25aad408f946b17fac1705a098b42f7bd33bd0b6d80218c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_session_mysql-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 97510dede2c55236e888572699a3983fb822f7d5a5cb5a3d7beac8f671c9fa0c
MD5 14a085eadaa1a3f55ca699065bbc42c3
BLAKE2b-256 75af945ed8ad9eae75bbb5b6d1b17c1757d9fd17db057faf4374744dce0e68fa

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