comparison sat_pubsub/backend.py @ 257:30988781f30d

fixed access check (getItems/notifications)
author Goffi <goffi@goffi.org>
date Sun, 28 Apr 2013 19:29:13 +0200
parents ea44c0986f47
children e5b83fbb0219
comparison
equal deleted inserted replaced
256:ea44c0986f47 257:30988781f30d
392 except InvalidFormat: 392 except InvalidFormat:
393 is_user_jid = False 393 is_user_jid = False
394 else: 394 else:
395 is_user_jid = bool(nodeIdentifierJID.user) 395 is_user_jid = bool(nodeIdentifierJID.user)
396 396
397 if is_user_jid and nodeIdentifierJID.userhost() != requestor.userhost(): 397 if is_user_jid and nodeIdentifierJID.userhostJID() != requestor.userhostJID():
398 #we have an user jid node, but not created by the owner of this jid 398 #we have an user jid node, but not created by the owner of this jid
399 print "Wrong creator" 399 print "Wrong creator"
400 raise error.Forbidden() 400 raise error.Forbidden()
401 401
402 nodeType = 'leaf' 402 nodeType = 'leaf'
459 - roster: mapping of jid to RosterItem as given by self.roster.getRoster 459 - roster: mapping of jid to RosterItem as given by self.roster.getRoster
460 - groups: list of authorized groups 460 - groups: list of authorized groups
461 @param entity: entity which must be in group 461 @param entity: entity which must be in group
462 @return: True if requestor is in roster""" 462 @return: True if requestor is in roster"""
463 roster, authorized_groups = roster_groups 463 roster, authorized_groups = roster_groups
464 _entity = entity.userhost() 464 _entity = entity.userhostJID()
465 465
466 if not _entity in roster: 466 if not _entity in roster:
467 raise error.NotInRoster 467 raise error.NotInRoster
468 if roster[_entity].groups.intersection(authorized_groups): 468 if roster[_entity].groups.intersection(authorized_groups):
469 return (True, roster) 469 return (True, roster)
747 747
748 for access_model, item_config, item in _items: 748 for access_model, item_config, item in _items:
749 if access_model == 'open': 749 if access_model == 'open':
750 allowed_items.append(item) 750 allowed_items.append(item)
751 elif access_model == 'roster': 751 elif access_model == 'roster':
752 _subscriber = subscriber.userhost() 752 _subscriber = subscriber.userhostJID()
753 if not _subscriber in roster: 753 if not _subscriber in roster:
754 continue 754 continue
755 #the subscriber is known, is he in the right group ? 755 #the subscriber is known, is he in the right group ?
756 authorized_groups = item_config[const.OPT_ROSTER_GROUPS_ALLOWED] 756 authorized_groups = item_config[const.OPT_ROSTER_GROUPS_ALLOWED]
757 if roster[_subscriber].groups.intersection(authorized_groups): 757 if roster[_subscriber].groups.intersection(authorized_groups):