mattupstate/flask-security — pull request #293 by ryanolson (2014-07-30 05:45:14+00:00)
Title: Added option to initialize with custom pwd_context

I added the option to initialized Flask-Security with a user defined pwd_context.

My primary motivation for this change was to enable the use of the same pwd_context with two separate login systems: Flask-Security and Flask-JWT.

Unfortunately, you can not just nic the extension's `.pwd_context` and use that in your Flask-JWT authorization handler, because Flask-Security salts the password with the `utils.get_hmac` function. Due to the salting outside of the `pwd_context`, you can not use the `pwd_context` outside of Flask-Security.

My changes allow for two things:

1) Using `SECURITY_PASSWORD_NO_SALT=True` and `SECURITY_PASSWORD_SALT=None`, you avoid the pre-salting of the password and then can use the extension's `.pwd_context` asis. Passlib generally does a good job at using randomized salts on each call to encrypt, but the user should be aware. This options requires that Flask-Security is initialized so you can use it's `pwd_context`

2) Using your own pwd_context passed via `init_app(..., pwd_contest=my_pwd_context)`, you can use `my_pwd_context` in two applications that share the same user model, where 1 application uses Flask-Security and the other solely uses Flask-JWT.

This help address some compatibility issues with Issue #215