No description, website, or topics provided.
Switch branches/tags
Nothing to show
Latest commit ca11184 Jan 14, 2013 @allanlei allanlei Update README.md
Permalink
Failed to load latest commit information.
flask_passlib wip Jan 14, 2013
.gitignore wip Jan 14, 2013
CHANGES wip Jan 14, 2013
LICENSE wip Jan 14, 2013
README.md Update README.md Jan 14, 2013
setup.py wip Jan 14, 2013

README.md

Flask-Passlib

Flask extension for Passlib.

This is still WIP, but give it a try.

Installation

pip install Flask-Passlib

Usage

The default usage will attempt to figure out what version of werkzeug is being used. As of werkzeug <= 0.8.3 only supports MD5 and SHA1.

app = Flask(__name__)
passlib = Passlib(app)

To change the passlib schemes, initialize with an instance of CryptContext and set the default scheme.

from passlib.context import LaxyCryptContext
from flask.ext.passlib.context import (werkzeug_salted_md5, werkzeug_salted_sha1, 
    werkzeug_salted_sha256, werkzeug_salted_sha512)
from passlib.hash import django_pbkdf2_sha256

passlib = Passlib(app, context=LazyCryptContext(
    schemes=[
        werkzeug_salted_md5,
        werkzeug_salted_sha1,
        werkzeug_salted_sha256,
        werkzeug_salted_sha512,         

        django_pbkdf2_sha256,
    ],
    default='django_pbkdf2_sha256',
))

In this example, we have the Flask defaults with Django's PBKDF2 SHA256.

Verifying

In Flask using werkzeug's

check_password_hash(password_hash, raw_password)

With Flask-Passlib

passlib.verify(raw_password, password_hash)
Generating

In Flask using werkzeug's

generate_password_hash(raw_password, method=.., salt_length=..)

With Flask-Passlib

passlib.encrypt(raw_password, method=..., salt_length=...)

Documentation

Also check out Passlib's documentation