def _callFUT(self, root): L = [] output = L.append from karl.security.workflow import reset_security_workflow reset_security_workflow(root, output) return L
def evolve(context): for path in exceptions: d = traverse(context, path) ob = d['context'] if model_path(ob) == path: if hasattr(ob, '__acl__'): ob.__custom_acl__ = ob.__acl__ reset_security_workflow(context)
def reset_profile(event): """ Subscriber for IUserAddedGroup and IUserRemovedGroup events. o Find the profile corresponding to the user and update its ACL by resettings its security workflow """ if (not IUserAddedGroup.providedBy(event) and not IUserRemovedGroup.providedBy(event)): return profiles = find_profiles(event.site) profile = profiles.get(event.id) if profile is not None: reset_security_workflow(profile)
def main(): parser = OptionParser(description=__doc__, usage='usage: %prog [options] username password') parser.add_option( '-C', '--config', dest='config', default=None, help="Specify a paster config file. Defaults to $CWD/etc/karl.ini") parser.add_option('--dry-run', '-n', dest='dry_run', action='store_true', default=False, help="Don't actually commit any transaction") path = '/' options, args = parser.parse_args() if args: path = args[0] config = options.config if config is None: config = get_default_config() root, closer = open_root(config) model = find_resource(root, path) def out(msg): sys.stderr.write(msg) sys.stderr.write('\n') sys.stderr.flush() try: reset_security_workflow(model, output=out) except: transaction.abort() raise else: if options.dry_run: print 'no transaction committed due to --dry-run' else: transaction.commit()
def update(self, profile): objectEventNotify(ObjectWillBeModifiedEvent(profile)) if profile.security_state == 'active': element = self.element login = self._element_value(element, 'username') username = profile.__name__ groups = self._groups(element) # Don't clobber user's community memberships users = find_users(profile) info = users.get_by_id(username) if info is not None: prev_groups = info['groups'] community_groups = [ g for g in prev_groups if g.startswith('group.community') ] groups = groups | set(community_groups) if info is not None: # keep old password password = info['password'] users.remove(username) users.add(username, login, password, groups, encrypted=True) else: # can it be that we have a new user here? password = get_random_password() users.add(username, login, password, groups, encrypted=False) user = users.get_by_id(username) request = get_current_request() settings = get_settings() app_url = settings.get('script_app_url') request_password_reset(user, profile, request, app_url=app_url) self._populate(profile) reset_security_workflow(profile) objectEventNotify(ObjectModifiedEvent(profile))
def main(): parser = OptionParser(description=__doc__, usage='usage: %prog [options] username password') parser.add_option('-C', '--config', dest='config', default=None, help="Specify a paster config file. Defaults to $CWD/etc/karl.ini") parser.add_option('--dry-run', '-n', dest='dry_run', action='store_true', default=False, help="Don't actually commit any transaction") path = '/' options, args = parser.parse_args() if args: path = args[0] config = options.config if config is None: config = get_default_config() root, closer = open_root(config) model = find_resource(root, path) def out(msg): sys.stderr.write(msg) sys.stderr.write('\n') sys.stderr.flush() try: reset_security_workflow(model, output=out) except: transaction.abort() raise else: if options.dry_run: print 'no transaction committed due to --dry-run' else: transaction.commit()
def update(self, profile): objectEventNotify(ObjectWillBeModifiedEvent(profile)) element = self.element login = _element_value(self, element, 'username') username = profile.__name__ password = _element_value(self, element, 'sha_password') groups = self._groups(element) users = find_users(profile) # Don't clobber user's community memberships prev_groups = users.get_by_id(username)['groups'] community_groups = [g for g in prev_groups if g.startswith('group.community')] groups = groups | set(community_groups) users.remove(username) users.add(username, login, password, groups, encrypted=True) self._populate(profile) reset_security_workflow(profile) objectEventNotify(ObjectModifiedEvent(profile))