Compare commits

..
26 Commits
Author SHA1 Message Date
Matt Wright 029466830d Bump version number to 1.5.4 2013-01-06 20:43:02 -05:00
Matt Wright 31595196fc Update CHANGES 2013-01-06 20:42:51 -05:00
Matt Wright 2a0b582911 Change csrf_enabled parameter in forms to check for incoming JSON data. Fix #63 2013-01-06 20:41:01 -05:00
Matt Wright f8fbd6cec8 Bump version number to 1.5.3 2012-12-23 16:47:20 -05:00
Matt Wright 9d11dd0787 Update dependency rules 2012-12-23 16:47:14 -05:00
Matt Wright 3a5a1b4f52 Bump version number to 1.5.2 2012-12-11 15:15:01 -05:00
Matt Wright 0724bd12a5 Remove stray file 2012-12-11 15:13:35 -05:00
Matt Wright c7e3e642fa Update CHANGES 2012-12-11 15:11:51 -05:00
Matt Wright ee4c8f2a3f Fix login_user method to actually return a True or False value as mentioned in mattupstate/flask-social-example#8 2012-12-11 15:10:26 -05:00
Matt Wright 1092ffc9ea Fix #45 2012-11-26 16:21:05 -05:00
Matt Wright f4b6eb9869 Fix table 2012-11-26 15:03:18 -05:00
Matt Wright 5e49a4e05b Bump version number to 1.5.1 2012-11-26 15:01:54 -05:00
Matt Wright adc50f07eb Update changelog 2012-11-26 14:59:12 -05:00
Matt Wright 874c758340 Add a test to test email subject configuration 2012-11-26 14:58:39 -05:00
Matt Wright ed031f01ba Concluding merge 2012-11-26 14:53:01 -05:00
Matt Wright 4cbae25ac0 Merge pull request #47 from doobeh/ISSUE43
Ability to manage email subjects from configuration.
2012-11-26 11:52:09 -08:00
Matt Wright 7f002ac612 Fixes #40 2012-11-26 14:41:51 -05:00
Matt Wright 9e8fcbc879 Merge pull request #48 from joshpurvis/nextbug
Pass 'next' url to form context during login
2012-11-26 11:17:40 -08:00
Josh Purvis c8a24a8647 Wrapped next args with get_url() 2012-11-24 17:31:05 -05:00
Josh Purvis e83a970b3a Pass 'next' url to form context variable 2012-11-24 17:02:04 -05:00
Anthony Plunkett 514d27fd66 Ability to manage email subjects from configuration. 2012-11-19 21:13:52 -05:00
Matt Wright 16976fce4e Merge pull request #46 from doobeh/ISSUE42
Flask-Mail documentation for basic functionality.
2012-11-16 14:50:39 -08:00
Anthony Plunkett 3dc2304d6e Flask-Mail documentation for basic functionality. 2012-11-16 17:30:12 -05:00
Matt Wright 7a04a857f2 Merge branch 'master' into develop 2012-10-11 22:17:00 -04:00
Matt Wright a107cd98db Fix setup.cfg 2012-10-11 22:14:32 -04:00
Matt Wright d7f52af371 Bump version number 2012-10-11 17:39:05 -04:00
17 changed files with 141 additions and 35 deletions
+32
View File
@@ -3,6 +3,38 @@ Flask-Security Changelog
Here you can see the full list of changes between each Flask-Security release.
Version 1.5.4
-------------
Released January 6th 2013
- Fix bug in forms with `csrf_enabled` parameter not accounting attempts to login using JSON data
Version 1.5.3
-------------
Released December 23rd 2012
- Change dependency requirement
Version 1.5.2
-------------
Released December 11th 2012
- Fix a small bug in `flask_security.utils.login_user` method
Version 1.5.1
-------------
Released November 26th 2012
- Fixed bug with `next` form variable
- Added better documentation regarding Flask-Mail configuration
- Added ability to configure email subjects
Version 1.5.0
-------------
+1 -1
View File
@@ -49,7 +49,7 @@ copyright = u'2012, Matt Wright'
# built documents.
#
# The short X.Y version.
version = '1.5.0'
version = '1.5.4'
# The full version, including alpha/beta/rc tags.
release = version
+22
View File
@@ -129,6 +129,28 @@ Feature Flags
to ``False``.
========================= ======================================================
Email
----------
.. tabularcolumns:: |p{6.5cm}|p{8.5cm}|
=========================================== ====================================
``SECURITY_EMAIL_SUBJECT_REGISTER`` Sets the subject for the
confirmation email. Defaults to
``Welcome``
``SECURITY_EMAIL_SUBJECT_PASSWORDLESS`` Sets the subject for the
passwordless feature. Defaults to
``Login instructions``
``SECURITY_EMAIL_SUBJECT_PASSWORD_NOTICE`` Sets subject for the password
notice. Defaults to
``Your password has been reset``
``SECURITY_EMAIL_SUBJECT_PASSWORD_RESET`` Sets the subject for the password
reset. Defaults to
``Password reset instructions``
``SECURITY_EMAIL_SUBJECT_CONFIRM`` Sets the subject for the email
confirmation message. Defaults to
``Please confirm your email``
=========================================== ====================================
Miscellaneous
-------------
+30
View File
@@ -68,3 +68,33 @@ using SQLAlchemy.::
if __name__ == '__main__':
app.run()
Mail Configuration
------------------
Flask-Security integrates with Flask-Mail to handle all email communications
between user and site, so it's important to configure Flask-Mail with your
email server details so Flask-Security can talk with Flask-Mail correctly.
The following code illustrates a basic setup, which could be added to the
basic application code in the previous section::
# At top of file
from flask_mail import Mail
# After 'Create app'
app.config['MAIL_SERVER'] = 'smtp.example.com'
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_SSL'] = True
app.config['MAIL_USERNAME'] = 'username'
app.config['MAIL_PASSWORD'] = 'password'
mail = Mail(app)
To learn more about the various Flask-Mail settings to configure it to work
with your particular email server configuration, please see the
`Flask-Mail documentation <http://packages.python.org/Flask-Mail/>`_
+1 -1
View File
@@ -10,7 +10,7 @@
:license: MIT, see LICENSE for more details.
"""
__version__ = '1.5.0'
__version__ = '1.5.4'
from .core import Security, RoleMixin, UserMixin, AnonymousUser, current_user
from .datastore import SQLAlchemyUserDatastore, MongoEngineUserDatastore
+4 -3
View File
@@ -14,7 +14,8 @@ from datetime import datetime
from flask import current_app as app, request
from werkzeug.local import LocalProxy
from .utils import send_mail, md5, url_for_security, get_token_status
from .utils import send_mail, md5, url_for_security, get_token_status,\
config_value
from .signals import user_confirmed, confirm_instructions_sent
@@ -39,7 +40,7 @@ def send_confirmation_instructions(user):
confirmation_link, token = generate_confirmation_link(user)
send_mail('Please confirm your email', user.email,
send_mail(config_value('EMAIL_SUBJECT_CONFIRM'), user.email,
'confirmation_instructions', user=user,
confirmation_link=confirmation_link)
@@ -52,7 +53,7 @@ def generate_confirmation_token(user):
:param user: The user to work with
"""
data = [user.id, md5(user.email)]
data = [str(user.id), md5(user.email)]
return _security.confirm_serializer.dumps(data)
+6 -1
View File
@@ -61,7 +61,12 @@ _default_config = {
'RESET_SALT': 'reset-salt',
'LOGIN_SALT': 'login-salt',
'REMEMBER_SALT': 'remember-salt',
'DEFAULT_HTTP_AUTH_REALM': 'Login Required'
'DEFAULT_HTTP_AUTH_REALM': 'Login Required',
'EMAIL_SUBJECT_REGISTER': 'Welcome',
'EMAIL_SUBJECT_CONFIRM': 'Please confirm your email',
'EMAIL_SUBJECT_PASSWORDLESS': 'Login instructions',
'EMAIL_SUBJECT_PASSWORD_NOTICE': 'Your password has been reset',
'EMAIL_SUBJECT_PASSWORD_RESET': 'Password reset instructions'
}
#: Default Flask-Security messages
+5 -2
View File
@@ -56,8 +56,11 @@ class UserDatastore(object):
self.role_model = role_model
def _prepare_role_modify_args(self, user, role):
role = role.name if isinstance(role, self.role_model) else role
return self.find_user(email=user.email), self.find_role(role)
if isinstance(user, basestring):
user = self.find_user(email=user.email)
if isinstance(role, basestring):
role = self.find_role(role)
return user, role
def _prepare_create_user_args(self, **kwargs):
kwargs.setdefault('active', True)
+5 -1
View File
@@ -42,7 +42,11 @@ def valid_user_email(form, field):
class Form(BaseForm):
def __init__(self, *args, **kwargs):
kwargs.setdefault('csrf_enabled', not current_app.testing)
if current_app.testing:
csrf_enabled = False
else:
csrf_enabled = request.json is None
kwargs.setdefault('csrf_enabled', csrf_enabled)
super(Form, self).__init__(*args, **kwargs)
+4 -3
View File
@@ -13,7 +13,8 @@ from flask import request, current_app as app
from werkzeug.local import LocalProxy
from .signals import login_instructions_sent
from .utils import send_mail, url_for_security, get_token_status
from .utils import send_mail, url_for_security, get_token_status, \
config_value
# Convenient references
@@ -32,7 +33,7 @@ def send_login_instructions(user):
url = url_for_security('token_login', token=token)
login_link = request.url_root[:-1] + url
send_mail('Login Instructions', user.email,
send_mail(config_value('EMAIL_SUBJECT_PASSWORDLESS'), user.email,
'login_instructions', user=user, login_link=login_link)
login_instructions_sent.send(dict(user=user, login_token=token),
@@ -44,7 +45,7 @@ def generate_login_token(user):
:param user: The user the token belongs to
"""
return _security.login_serializer.dumps([user.id])
return _security.login_serializer.dumps([str(user.id)])
def login_token_status(token):
+4 -4
View File
@@ -14,7 +14,7 @@ from werkzeug.local import LocalProxy
from .signals import password_reset, reset_password_instructions_sent
from .utils import send_mail, md5, encrypt_password, url_for_security, \
get_token_status
get_token_status, config_value
# Convenient references
@@ -32,7 +32,7 @@ def send_reset_password_instructions(user):
url = url_for_security('reset_password', token=token)
reset_link = request.url_root[:-1] + url
send_mail('Password reset instructions', user.email,
send_mail(config_value('EMAIL_SUBJECT_PASSWORD_RESET'), user.email,
'reset_instructions',
user=user, reset_link=reset_link)
@@ -45,7 +45,7 @@ def send_password_reset_notice(user):
:param user: The user to send the notice to
"""
send_mail('Your password has been reset', user.email,
send_mail(config_value('EMAIL_SUBJECT_PASSWORD_NOTICE'), user.email,
'reset_notice', user=user)
@@ -54,7 +54,7 @@ def generate_reset_password_token(user):
:param user: The user to work with
"""
data = [user.id, md5(user.password)]
data = [str(user.id), md5(user.password)]
return _security.reset_serializer.dumps(data)
+3 -2
View File
@@ -14,7 +14,8 @@ from werkzeug.local import LocalProxy
from .confirmable import generate_confirmation_link
from .signals import user_registered
from .utils import do_flash, get_message, send_mail, encrypt_password
from .utils import do_flash, get_message, send_mail, encrypt_password, \
config_value
# Convenient references
_security = LocalProxy(lambda: app.extensions['security'])
@@ -35,7 +36,7 @@ def register_user(**kwargs):
user_registered.send(dict(user=user, confirm_token=token),
app=app._get_current_object())
send_mail('Welcome', user.email, 'welcome',
send_mail(config_value('EMAIL_SUBJECT_REGISTER'), user.email, 'welcome',
user=user, confirmation_link=confirmation_link)
return user
+11 -9
View File
@@ -38,23 +38,25 @@ _pwd_context = LocalProxy(lambda: _security.pwd_context)
def login_user(user, remember=True):
"""Performs the login and sends the appropriate signal."""
_login_user(user, remember)
if not _login_user(user, remember):
return False
if _security.trackable:
old_current, new_current = user.current_login_at, datetime.utcnow()
user.last_login_at = old_current or new_current
user.current_login_at = new_current
old_current_login, new_current_login = user.current_login_at, datetime.utcnow()
remote_addr = request.remote_addr or 'untrackable'
old_current, new_current = user.current_login_ip, remote_addr
user.last_login_ip = old_current or new_current
user.current_login_ip = new_current
old_current_ip, new_current_ip = user.current_login_ip, remote_addr
user.last_login_at = old_current_login or new_current_login
user.current_login_at = new_current_login
user.last_login_ip = old_current_ip or new_current_ip
user.current_login_ip = new_current_ip
user.login_count = user.login_count + 1 if user.login_count else 1
_datastore.put(user)
_datastore.put(user)
identity_changed.send(current_app._get_current_object(),
identity=Identity(user.id))
return True
def logout_user():
+3
View File
@@ -76,6 +76,9 @@ def login():
if not request.json:
return redirect(get_post_login_redirect())
form.next.data = get_url(request.args.get('next')) \
or get_url(request.form.get('next')) or ''
if request.json:
return _render_json(form, True)
+1 -1
View File
@@ -3,4 +3,4 @@ source-dir = docs/
build-dir = docs/_build
[upload_sphinx]
upload-dir = docs/_build
upload-dir = docs/_build/html
+7 -7
View File
@@ -20,7 +20,7 @@ from setuptools import setup
setup(
name='Flask-Security',
version='1.5.0',
version='1.5.4',
url='https://github.com/mattupstate/flask-security',
license='MIT',
author='Matt Wright',
@@ -35,12 +35,12 @@ setup(
platforms='any',
install_requires=[
'Flask>=0.8',
'Flask-Login==0.1.3',
'Flask-Mail==0.7.3',
'Flask-Principal==0.3.3',
'Flask-WTF==0.8',
'itsdangerous==0.17',
'passlib==1.6.1',
'Flask-Login>=0.1.3',
'Flask-Mail>=0.7.3',
'Flask-Principal>=0.3.3',
'Flask-WTF>=0.8',
'itsdangerous>=0.17',
'passlib>=1.6.1',
],
test_suite='nose.collector',
tests_require=[
+2
View File
@@ -121,6 +121,7 @@ class ConfirmableTests(SecurityTest):
AUTH_CONFIG = {
'SECURITY_CONFIRMABLE': True,
'SECURITY_REGISTERABLE': True,
'SECURITY_EMAIL_SUBJECT_REGISTER': 'Custom welcome subject',
'USER_COUNT': 1
}
@@ -148,6 +149,7 @@ class ConfirmableTests(SecurityTest):
self.register(e)
self.assertEqual(len(outbox), 1)
self.assertIn(e, outbox[0].html)
self.assertEqual('Custom welcome subject', outbox[0].subject)
def test_confirm_email(self):
e = 'dude@lp.com'