diff options
author | Nathan Kinder <nkinder@redhat.com> | 2015-04-01 17:36:22 -0700 |
---|---|---|
committer | Rob Crittenden <rcritten@redhat.com> | 2015-04-01 23:18:39 -0400 |
commit | 8ffd2629c6554124e7e3b15dce10275a2efd8261 (patch) | |
tree | 32212efa6f6884ba357955dbcaab93d955744b90 /ipsilon/providers/saml2/admin.py | |
parent | 9600cff7a3f93529ab56044968b489030f74b76c (diff) | |
download | ipsilon-8ffd2629c6554124e7e3b15dce10275a2efd8261.tar.gz ipsilon-8ffd2629c6554124e7e3b15dce10275a2efd8261.tar.xz ipsilon-8ffd2629c6554124e7e3b15dce10275a2efd8261.zip |
Validate SP names for admin pages and REST
We were previously only validating the SP name in the admin pages
for SP creation and update. The REST API would allow a SP to be
created with an invalid name, which would break the ability to
manage that SP in the admin pages.
This patch moves the SP name validation logic out of the admin
page code and centralizes it in the provider creation code. This
ensures that validation will occur regardless of the interface
that is used. In addition, a helper method is added to allow
the admin page to check if a name is valid during update operations.
https://fedorahosted.org/ipsilon/ticket/102
Signed-off-by: Nathan Kinder <nkinder@redhat.com>
Reviewed-by: Rob Crittenden <rcritten@redhat.com>
Diffstat (limited to 'ipsilon/providers/saml2/admin.py')
-rw-r--r-- | ipsilon/providers/saml2/admin.py | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/ipsilon/providers/saml2/admin.py b/ipsilon/providers/saml2/admin.py index 0ab2a41..2503be1 100644 --- a/ipsilon/providers/saml2/admin.py +++ b/ipsilon/providers/saml2/admin.py @@ -23,13 +23,9 @@ from ipsilon.admin.common import ADMIN_STATUS_WARN from ipsilon.providers.saml2.provider import ServiceProvider from ipsilon.providers.saml2.provider import ServiceProviderCreator from ipsilon.providers.saml2.provider import InvalidProviderId -import re import requests -VALID_IN_NAME = r'[^\ a-zA-Z0-9]' - - class NewSPAdminPage(AdminPage): def __init__(self, site, parent): @@ -68,12 +64,6 @@ class NewSPAdminPage(AdminPage): cherrypy.request.content_type,)) for key, value in kwargs.iteritems(): if key == 'name': - if re.search(VALID_IN_NAME, value): - message = "Invalid name!" \ - " Use only numbers and letters" - message_type = ADMIN_STATUS_ERROR - return self.form_new(message, message_type) - name = value elif key == 'metatext': if len(value) > 0: @@ -156,7 +146,7 @@ class SPAdminPage(AdminPage): return False if self.user.is_admin or self.user.name == self.sp.owner: - if re.search(VALID_IN_NAME, value): + if not self.sp.is_valid_name(value): err = "Invalid name! Use only numbers and letters" raise InvalidValueFormat(err) |