User's email format hasn't been checked

Bug #1218682 reported by Haiwei Xu
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Invalid
Wishlist
Unassigned
oslo-incubator
Won't Fix
Wishlist
Unassigned
python-keystoneclient
Invalid
Wishlist
Unassigned

Bug Description

When a user is created, the email attribute can be in any format.
I think it's necessary to do the format check of email.

$ keystone user-list
+----------------------------------+----------------+---------+-----------------------+
| id | name | enabled | email |
+----------------------------------+----------------+---------+-----------------------+
| 4d0458857e604f0e9ceeefdea61f92a2 | testuser | True | test_user@@ |

Haiwei Xu (xu-haiwei)
Changed in python-keystoneclient:
assignee: nobody → Haiwei Xu (xu-haiwei)
Revision history for this message
Dolph Mathews (dolph) wrote :

This sounds like a good candidate for a wishlist item against oslo, as similar work for 'name' validation has been proposed there... and it would definitely be painful to have conflicting 'email' validation algorithms floating around openstack (it's a surprisingly difficult problem to validate email addresses).

'email' is a non-spec attribute in the v3 identity API so I'm not 100% sure it makes sense to add keystone or do verification on the server side.

Changed in python-keystoneclient:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Haiwei Xu (xu-haiwei) wrote :

Hi Dolph,

It seems jsonschema will be used to keystone, and I found there were email format validation in it. What about using jsonschema after it is imported to keystone. Before that we can just use the regular expression like "^[A-Za-z0-9][A-Za-z0-9\.]*@([A-Za-z0-9]+\.)+[A-Za-z0-9]+$".

On the other hand I think it's necessary to add the check in both server and the client sides. What do you think?

Revision history for this message
Dolph Mathews (dolph) wrote :

As I mentioned above, it's a non-spec attribute, so there's no guarantee that an email will be provided.

If you want to pursue it on the server-side, the fix would go in the create_user() and update_user() methods of the identity Manager class.

Changed in keystone:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Dolph Mathews (dolph) wrote :

Regarding the regular expression, it failed on the second valid email address I gave it (<email address hidden>). If jsonschema is sufficiently capable, go ahead and use that. jsonschema is already required via global requirements [1] as:

  jsonschema>=1.3.0,!=1.4.0

[1]: https://github.com/openstack/requirements/blob/master/global-requirements.txt

Revision history for this message
Dolph Mathews (dolph) wrote :

You can find several examples to test email validation algorithms against on wikipedia:

  http://en.wikipedia.org/wiki/Email_address#Examples

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-keystoneclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/46041

Changed in python-keystoneclient:
status: Triaged → In Progress
Revision history for this message
Haiwei Xu (xu-haiwei) wrote :

Hi Dolph,

I have added the validation by using the jsonschema though jsonschema does not satisfy all the examples in the wikipedia you suggested. IMO it's not bad to use jsonschema since it is provided in keystone.

Changed in oslo:
importance: Undecided → Wishlist
status: New → Triaged
Revision history for this message
Rodrigo Duarte (rodrigodsousa) wrote :

Hi,

Joining the discussion.

After doing some research, maybe a better idea is just to check points and @ using "/.+@.+\..+/i", since jsonschema just checks if the provided string contains @, doesn't make sense to import the whole library (as pointed by the comments in the patch).

What do you think?

Revision history for this message
Lance Bragstad (lbragstad) wrote :

I have a patch up in Keystone that will help with this if you're still going for the jsonschema route.

https://review.openstack.org/#/c/86483/23/keystone/common/validation/parameter_types.py

I am working on implementing validation on the Keystone APIs as I go, and I haven't gotten to the Identity API yet. Actually implementing this on the Identity API would look similar to:

https://review.openstack.org/#/c/86484/

For more information, I've detailed this work in a keystone-spec:

https://github.com/openstack/keystone-specs/blob/master/specs/juno/keystone-api-validation.rst

Changed in oslo:
assignee: nobody → Ryan Oshima (ryan-oshima)
assignee: Ryan Oshima (ryan-oshima) → nobody
Changed in keystone:
assignee: nobody → Ryan Oshima (ryan-oshima)
Changed in keystone:
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/132122

Changed in keystone:
assignee: Ryan Oshima (ryan-oshima) → Lance Bragstad (lbragstad)
Changed in python-keystoneclient:
assignee: Haiwei Xu (xu-haiwei) → Abhishek Talwar (abhishek-talwar)
Changed in python-keystoneclient:
assignee: Abhishek Talwar (abhishek-talwar) → nobody
Changed in keystone:
assignee: Lance Bragstad (lbragstad) → Lin Hua Cheng (lin-hua-cheng)
Revision history for this message
David Stanek (dstanek) wrote :

Unassigned due to lack of activity.

Changed in keystone:
assignee: Lin Hua Cheng (lin-hua-cheng) → nobody
Changed in oslo-incubator:
status: Triaged → Won't Fix
Revision history for this message
Steve Martinelli (stevemar) wrote :

marked this as invalid for keystoneclient since the server should respond with validation.

this can be completed by extending the current json schema for user create and update: https://github.com/openstack/keystone/blob/master/keystone/identity/schema.py#L24-L33

this should be for V3 only.

Changed in keystone:
status: In Progress → Triaged
Changed in python-keystoneclient:
status: In Progress → Invalid
Revision history for this message
Henry Nash (henry-nash) wrote :

I agree with the concern that since email is not a supported attribute (for storage) in the server (we had that debate), it would seem strange to add code in the server for validation. Seems to me there are two scenarios:

1) If it is being stored in Keystone as an extra, then keystone shouldn't know or care about the format - the client has to do this
2) If the user entities are backed by LDAP, then Keystone is just a pass through - and the LDAP store should reject invalid email entries (assuming you are operating R/W mode).

Revision history for this message
Steve Martinelli (stevemar) wrote :

We can enforce this at the client level then, openstackclient would be a nice spot to improve

Revision history for this message
Morgan Fainberg (mdrnstm) wrote :

UNless email becomes a top-level attribute this is not something we will validate. Validate in the client or make it a top-level attribute.

Changed in keystone:
status: Triaged → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.