diff options
author | Nathaniel McCallum <npmccallum@redhat.com> | 2014-05-05 10:41:20 -0400 |
---|---|---|
committer | Alexander Bokovoy <abokovoy@redhat.com> | 2014-05-23 11:53:02 +0300 |
commit | db7d0219bac72daa270ee28d5db5c18ea41fb8b1 (patch) | |
tree | ba75108d466ef0e04aa54c70582f072e3f2c4ba5 | |
parent | 5afa3c18159ae3f56a5a73158b526fcf8ff4d427 (diff) | |
download | freeipa-db7d0219bac72daa270ee28d5db5c18ea41fb8b1.tar.gz freeipa-db7d0219bac72daa270ee28d5db5c18ea41fb8b1.tar.xz freeipa-db7d0219bac72daa270ee28d5db5c18ea41fb8b1.zip |
Default the token owner to the person adding the token
Creating tokens for yourself is the most common operation. Making this the
default optimizes for the common case.
Reviewed-By: Simo Sorce <simo@redhat.com>
Reviewed-By: Jan Cholasta <jcholast@redhat.com>
-rw-r--r-- | ipalib/plugins/otptoken.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/ipalib/plugins/otptoken.py b/ipalib/plugins/otptoken.py index 027c28f85..b264287c3 100644 --- a/ipalib/plugins/otptoken.py +++ b/ipalib/plugins/otptoken.py @@ -244,7 +244,14 @@ class otptoken_add(LDAPCreate): if tattr in entry_attrs: del entry_attrs[tattr] - # Resolve the user's dn + # If owner was not specified, default to the person adding this token. + if 'ipatokenowner' not in entry_attrs: + result = self.api.Command.user_find(whoami=True)['result'] + if result: + cur_uid = result[0]['uid'][0] + entry_attrs.setdefault('ipatokenowner', cur_uid) + + # Resolve the owner's dn _normalize_owner(self.api.Object.user, entry_attrs) # Get the issuer for the URI |