Skip to content

Commit

Permalink
[#2784] User email is treated as sensitive data
Browse files Browse the repository at this point in the history
Cherry-pick of 21ca66c

Conflicts:

	ckan/controllers/user.py
  • Loading branch information
Ian Murray committed Aug 1, 2012
1 parent cb42c5e commit eceb1ea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions ckan/controllers/user.py
Expand Up @@ -356,12 +356,18 @@ def request_reset(self):

def perform_reset(self, id):
context = {'model': model, 'session': model.Session,
'user': c.user}
'user': c.user,
'keep_sensitive_data': True}

data_dict = {'id':id}

try:
user_dict = get_action('user_show')(context,data_dict)
user_dict = get_action('user_show')(context, data_dict)

# Be a little paranoid, and get rid of sensitive data that's
# not needed.
user_dict.pop('apikey', None)
user_dict.pop('reset_key', None)
user_obj = context['user_obj']
except NotFound, e:
abort(404, _('User not found'))
Expand Down
1 change: 1 addition & 0 deletions ckan/lib/dictization/model_dictize.py
Expand Up @@ -364,6 +364,7 @@ def user_dictize(user, context):
# If not sysadmin or the same user, strip sensible info
result_dict.pop('apikey', None)
result_dict.pop('reset_key', None)
result_dict.pop('email', None)

return result_dict

Expand Down
9 changes: 6 additions & 3 deletions ckan/tests/lib/test_dictization.py
Expand Up @@ -894,7 +894,6 @@ def test_16_group_dictized(self):
'users': [{'about': u'I love reading Annakarenina. My site: <a href="http://anna.com">anna.com</a>',
'display_name': u'annafan',
'capacity' : 'public',
'email': None,
'email_hash': 'd41d8cd98f00b204e9800998ecf8427e',
'fullname': None,
'name': u'annafan',
Expand Down Expand Up @@ -1088,6 +1087,7 @@ def test_22_user_dictize_as_sysadmin(self):
# Check sensitive data is available
assert 'apikey' in user_dict
assert 'reset_key' in user_dict
assert 'email' in user_dict

# Passwords should never be available
assert 'password' not in user_dict
Expand All @@ -1111,6 +1111,7 @@ def test_23_user_dictize_as_same_user(self):
# Check sensitive data is available
assert 'apikey' in user_dict
assert 'reset_key' in user_dict
assert 'email' in user_dict

# Passwords should never be available
assert 'password' not in user_dict
Expand All @@ -1131,9 +1132,10 @@ def test_24_user_dictize_as_other_user(self):
assert 'name' in user_dict
assert 'about' in user_dict

# Check sensitive data is available
# Check sensitive data is not available
assert 'apikey' not in user_dict
assert 'reset_key' not in user_dict
assert 'email' not in user_dict

# Passwords should never be available
assert 'password' not in user_dict
Expand All @@ -1154,9 +1156,10 @@ def test_25_user_dictize_as_anonymous(self):
assert 'name' in user_dict
assert 'about' in user_dict

# Check sensitive data is available
# Check sensitive data is not available
assert 'apikey' not in user_dict
assert 'reset_key' not in user_dict
assert 'email' not in user_dict

# Passwords should never be available
assert 'password' not in user_dict

0 comments on commit eceb1ea

Please sign in to comment.