summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/otptoken.py
diff options
context:
space:
mode:
authorNathaniel McCallum <npmccallum@redhat.com>2014-06-19 12:30:23 -0400
committerMartin Kosek <mkosek@redhat.com>2014-06-20 21:27:50 +0200
commitcf8f143e9823c06ed069c6a031c0c4aa80288840 (patch)
tree0dcdd4f253763dbdb47d44a2942134d1f4951d2a /ipalib/plugins/otptoken.py
parent0eef37908c580f4550618244e661594138f7b382 (diff)
downloadfreeipa-cf8f143e9823c06ed069c6a031c0c4aa80288840.tar.gz
freeipa-cf8f143e9823c06ed069c6a031c0c4aa80288840.tar.xz
freeipa-cf8f143e9823c06ed069c6a031c0c4aa80288840.zip
Make otptoken use os.urandom() for random data
This also fixes an error where the default value was not respecting the KEY_LENGTH variable. Reviewed-By: Simo Sorce <ssorce@redhat.com>
Diffstat (limited to 'ipalib/plugins/otptoken.py')
-rw-r--r--ipalib/plugins/otptoken.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py
index 9c7bd412b..d834d582a 100644
--- a/ipalib/plugins/otptoken.py
+++ b/ipalib/plugins/otptoken.py
@@ -25,9 +25,9 @@ from ipalib.errors import PasswordMismatch, ConversionError, LastMemberError, No
from ipalib.request import context
import base64
import uuid
-import random
import urllib
import qrcode
+import os
__doc__ = _("""
OTP Tokens
@@ -182,7 +182,7 @@ class otptoken(LDAPObject):
OTPTokenKey('ipatokenotpkey?',
cli_name='key',
label=_('Key'),
- default_from=lambda: "".join(random.SystemRandom().sample(map(chr, range(256)), 10)),
+ default_from=lambda: os.urandom(KEY_LENGTH),
autofill=True,
flags=('no_display', 'no_update', 'no_search'),
),