Validate key in otptoken-add

Verify that key is not empty when adding otp token. If it is empty, raise an
appropriate error.

https://fedorahosted.org/freeipa/ticket/6200

Reviewed-By: Martin Basti <mbasti@redhat.com>
This commit is contained in:
Tomas Krizek 2016-08-24 13:29:37 +02:00 committed by Martin Basti
parent c346a2d1d1
commit 6f9a029bf5

View File

@ -323,6 +323,10 @@ class otptoken_add(LDAPCreate):
except (NotFound, IndexError):
pass
# Check if key is not empty
if entry_attrs['ipatokenotpkey'] is None:
raise ValidationError(name='key', error=_(u'cannot be empty'))
# Build the URI parameters
args = {}
args['issuer'] = issuer