summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/user.py
diff options
context:
space:
mode:
authorNathaniel McCallum <npmccallum@redhat.com>2014-05-02 16:44:30 -0400
committerMartin Kosek <mkosek@redhat.com>2014-06-16 10:13:59 +0200
commit98851256f94efe55b873f01aa46b2cdcda4a3efb (patch)
tree1a1ea373a57c2ff2407934fb37941fc8bc2bba79 /ipalib/plugins/user.py
parentba53299b98977308966039fad9518c79296bccbf (diff)
downloadfreeipa-98851256f94efe55b873f01aa46b2cdcda4a3efb.tar.gz
freeipa-98851256f94efe55b873f01aa46b2cdcda4a3efb.tar.xz
freeipa-98851256f94efe55b873f01aa46b2cdcda4a3efb.zip
Add support for managedBy to tokens
This also constitutes a rethinking of the token ACIs after the introduction of SELFDN support. Admins, as before, have full access to all token permissions. Normal users have read/search/compare access to all of the non-secret data for tokens assigned to them, whether managed by them or not. Users can add tokens if, and only if, they will also manage this token. Managers can also read/search/compare tokens they manage. Additionally, they can write non-secret data to their managed tokens and delete them. When a normal user self-creates a token (the default behavior), then managedBy is automatically set. When an admin creates a token for another user (or no owner is assigned at all), then managed by is not set. In this second case, the token is effectively read-only for the assigned owner. This behavior enables two important other behaviors. First, an admin can create a hardware token and assign it to the user as a read-only token. Second, when the user is deleted, only his self-managed tokens are deleted. All other (read-only) tokens are instead orphaned. This permits the same token object to be reasigned to another user without loss of any counter data. https://fedorahosted.org/freeipa/ticket/4228 https://fedorahosted.org/freeipa/ticket/4259 Reviewed-By: Jan Cholasta <jcholast@redhat.com>
Diffstat (limited to 'ipalib/plugins/user.py')
-rw-r--r--ipalib/plugins/user.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index a1b0643a3..2f700b60f 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -855,12 +855,17 @@ class user_del(LDAPDelete):
assert isinstance(dn, DN)
check_protected_member(keys[-1])
- # Delete all tokens owned by this user
+ # Delete all tokens owned and managed by this user.
+ # Orphan all tokens owned but not managed by this user.
owner = self.api.Object.user.get_primary_key_from_dn(dn)
results = self.api.Command.otptoken_find(ipatokenowner=owner)['result']
for token in results:
+ orphan = not [x for x in token.get('managedby_user', []) if x == owner]
token = self.api.Object.otptoken.get_primary_key_from_dn(token['dn'])
- self.api.Command.otptoken_del(token)
+ if orphan:
+ self.api.Command.otptoken_mod(token, ipatokenowner=None)
+ else:
+ self.api.Command.otptoken_del(token)
return dn