def update_user(self, context, user_id, user_ref): user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) return self.driver.update_user(user_id, user)
def update_user(self, user_id, user_ref, initiator=None): old_user_ref = self.get_user(user_id) user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) if 'domain_id' in user: self.resource_api.get_domain(user['domain_id']) if 'id' in user: if user_id != user['id']: raise exception.ValidationError(_('Cannot change user ID')) # Since any ID in the user dict is now irrelevant, remove its so as # the driver layer won't be confused by the fact the this is the # public ID not the local ID user.pop('id') self.get_user.invalidate(self, old_user_ref['id']) self.get_user_by_name.invalidate(self, old_user_ref['name'], old_user_ref['domain_id']) ref = self.driver.update_user(user_id, user) notifications.Audit.updated(self._USER, user_id, initiator) enabled_change = ((user.get('enabled') is False) and user['enabled'] != old_user_ref.get('enabled')) if enabled_change or user.get('password') is not None: self.emit_invalidate_user_token_persistence(user_id) return ref
def update_user(self, user_id, user_ref): user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) if 'domain_id' in user: self.assignment_api.get_domain(user['domain_id']) if 'id' in user: if user_id != user['id']: raise exception.ValidationError(_('Cannot change user ID')) # Since any ID in the user dict is now irrelevant, remove its so as # the driver layer won't be confused by the fact the this is the # public ID not the local ID user.pop('id') domain_id, driver, entity_id = ( self._get_domain_driver_and_entity_id(user_id)) user = self._clear_domain_id_if_domain_unaware(driver, user) ref = driver.update_user(entity_id, user) if user.get('enabled') is False or user.get('password') is not None: if self.revoke_api: self.revoke_api.revoke_by_user(user_id) self.token_api.delete_tokens_for_user(user_id) return self._set_domain_id_and_mapping( ref, domain_id, driver, mapping.EntityType.USER)
def update_user(self, user_id, user_ref): old_user_ref = self.get_user(user_id) user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) if 'domain_id' in user: self.resource_api.get_domain(user['domain_id']) if 'id' in user: if user_id != user['id']: raise exception.ValidationError(_('Cannot change user ID')) # Since any ID in the user dict is now irrelevant, remove its so as # the driver layer won't be confused by the fact the this is the # public ID not the local ID user.pop('id') domain_id, driver, entity_id = ( self._get_domain_driver_and_entity_id(user_id)) user = self._clear_domain_id_if_domain_unaware(driver, user) ref = driver.update_user(entity_id, user) enabled_change = ((user.get('enabled') is False) and user['enabled'] != old_user_ref.get('enabled')) if enabled_change or user.get('password') is not None: self.emit_invalidate_user_token_persistence(user_id) return self._set_domain_id_and_mapping(ref, domain_id, driver, mapping.EntityType.USER)
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) try: self.get_user(user_id) except exception.UserNotFound: pass else: msg = 'Duplicate ID, %s.' % user_id raise exception.Conflict(type='user', details=msg) try: self.get_user_by_name(user['name'], user['domain_id']) except exception.UserNotFound: pass else: msg = 'Duplicate name, %s.' % user['name'] raise exception.Conflict(type='user', details=msg) user = utils.hash_user_password(user) new_user = user.copy() new_user.setdefault('groups', []) self.db.set('user-%s' % user_id, new_user) self.db.set('user_name-%s' % new_user['name'], new_user) user_list = set(self.db.get('user_list', [])) user_list.add(user_id) self.db.set('user_list', list(user_list)) return identity.filter_user(new_user)
def update_user(self, user_id, user): user = self._validate_domain(user) if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) return self._set_default_domain(self.user.update(user_id, user))
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) try: self.get_user(user_id) except exception.UserNotFound: pass else: msg = 'Duplicate ID, %s.' % user_id raise exception.Conflict(type='user', details=msg) try: self.get_user_by_name(user['name']) except exception.UserNotFound: pass else: msg = 'Duplicate name, %s.' % user['name'] raise exception.Conflict(type='user', details=msg) user = _ensure_hashed_password(user) self.db.set('user-%s' % user_id, user) self.db.set('user_name-%s' % user['name'], user) user_list = set(self.db.get('user_list', [])) user_list.add(user_id) self.db.set('user_list', list(user_list)) return user
def update_user(self, user_id, user_ref): user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) return self.driver.update_user(user_id, user)
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) user = utils.hash_user_password(user) session = self.get_session() with session.begin(): user_ref = User.from_dict(user) session.add(user_ref) session.flush() return identity.filter_user(user_ref.to_dict())
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) user = _ensure_hashed_password(user) session = self.get_session() with session.begin(): user_ref = User.from_dict(user) session.add(user_ref) session.flush() return user_ref.to_dict()
def create_user(self, user_id, user): user["name"] = clean.user_name(user["name"]) if "enabled" not in user: user["enabled"] = True user = utils.hash_user_password(user) session = self.get_session() with session.begin(): user_ref = User.from_dict(user) session.add(user_ref) session.flush() return identity.filter_user(user_ref.to_dict())
def update_user(self, user_id, user_ref, domain_scope=None): user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) domain_id, driver = self._get_domain_id_and_driver(domain_scope) if not driver.is_domain_aware(): user = self._clear_domain_id(user) ref = driver.update_user(user_id, user) if not driver.is_domain_aware(): ref = self._set_domain_id(ref, domain_id) return ref
def create_user(self, user_id, user_ref): user = user_ref.copy() user['name'] = clean.user_name(user['name']) user.setdefault('enabled', True) user['enabled'] = clean.user_enabled(user['enabled']) # For creating a user, the domain is in the object itself domain_id = user_ref['domain_id'] driver = self._select_identity_driver(domain_id) if not driver.is_domain_aware(): user = self._clear_domain_id(user) ref = driver.create_user(user_id, user) if not driver.is_domain_aware(): ref = self._set_domain_id(ref, domain_id) return ref
def update_user(self, user_id, user_ref, domain_scope=None): user = user_ref.copy() if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) domain_id, driver = self._get_domain_id_and_driver(domain_scope) if not driver.is_domain_aware(): user = self._clear_domain_id(user) ref = driver.update_user(user_id, user) if user.get('enabled') is False or user.get('password') is not None: self.token_api.delete_tokens_for_user(user_id) if not driver.is_domain_aware(): ref = self._set_domain_id(ref, domain_id) return ref
def update_user(self, user_id, user_ref, domain_scope=None): user = user_ref.copy() if "name" in user: user["name"] = clean.user_name(user["name"]) if "enabled" in user: user["enabled"] = clean.user_enabled(user["enabled"]) domain_id, driver = self._get_domain_id_and_driver(domain_scope) if not driver.is_domain_aware(): user = self._clear_domain_id(user) ref = driver.update_user(user_id, user) if user.get("enabled") is False or user.get("password") is not None: if self.revoke_api: self.revoke_api.revoke_by_user(user_id) self.token_api.delete_tokens_for_user(user_id) if not driver.is_domain_aware(): ref = self._set_domain_id(ref, domain_id) return ref
def create_user(self, user_ref, initiator=None): user = user_ref.copy() user['name'] = clean.user_name(user['name']) user.setdefault('enabled', True) user['enabled'] = clean.user_enabled(user['enabled']) domain_id = user['domain_id'] self.resource_api.get_domain(domain_id) # For creating a user, the domain is in the object itself domain_id = user_ref['domain_id'] # Generate a local ID - in the future this might become a function of # the underlying driver so that it could conform to rules set down by # that particular driver type. user['id'] = uuid.uuid4().hex ref = self.driver.create_user(user['id'], user) notifications.Audit.created(self._USER, user['id'], initiator) return ref
def create_user(self, user_ref): user = user_ref.copy() user['name'] = clean.user_name(user['name']) user.setdefault('enabled', True) user['enabled'] = clean.user_enabled(user['enabled']) domain_id = user['domain_id'] self.assignment_api.get_domain(domain_id) # For creating a user, the domain is in the object itself domain_id = user_ref['domain_id'] driver = self._select_identity_driver(domain_id) user = self._clear_domain_id_if_domain_unaware(driver, user) # Generate a local ID - in the future this might become a function of # the underlying driver so that it could conform to rules set down by # that particular driver type. user['id'] = uuid.uuid4().hex ref = driver.create_user(user['id'], user) return self._set_domain_id_and_mapping( ref, domain_id, driver, mapping.EntityType.USER)
def create_user(self, user_ref): user = user_ref.copy() user['name'] = clean.user_name(user['name']) user.setdefault('enabled', True) user['enabled'] = clean.user_enabled(user['enabled']) domain_id = user['domain_id'] self.resource_api.get_domain(domain_id) # For creating a user, the domain is in the object itself domain_id = user_ref['domain_id'] driver = self._select_identity_driver(domain_id) user = self._clear_domain_id_if_domain_unaware(driver, user) # Generate a local ID - in the future this might become a function of # the underlying driver so that it could conform to rules set down by # that particular driver type. user['id'] = uuid.uuid4().hex ref = driver.create_user(user['id'], user) return self._set_domain_id_and_mapping(ref, domain_id, driver, mapping.EntityType.USER)
def update_user(self, user_id, user): if 'name' in user: user['name'] = clean.user_name(user['name']) session = self.get_session() if 'id' in user and user_id != user['id']: raise exception.ValidationError('Cannot change user ID') with session.begin(): user_ref = session.query(User).filter_by(id=user_id).first() if user_ref is None: raise exception.UserNotFound(user_id=user_id) old_user_dict = user_ref.to_dict() user = _ensure_hashed_password(user) for k in user: old_user_dict[k] = user[k] new_user = User.from_dict(old_user_dict) user_ref.name = new_user.name user_ref.extra = new_user.extra session.flush() return user_ref
def update_user(self, user_id, user): if 'name' in user: user['name'] = clean.user_name(user['name']) existing = self.db.get('user_name-%s' % user['name']) if existing and user_id != existing['id']: msg = 'Duplicate name, %s.' % user['name'] raise exception.Conflict(type='user', details=msg) # get the old name and delete it too try: old_user = self.db.get('user-%s' % user_id) except exception.NotFound: raise exception.UserNotFound(user_id=user_id) new_user = old_user.copy() user = utils.hash_user_password(user) new_user.update(user) if new_user['id'] != user_id: raise exception.ValidationError('Cannot change user ID') self.db.delete('user_name-%s' % old_user['name']) self.db.set('user-%s' % user_id, new_user) self.db.set('user_name-%s' % new_user['name'], new_user) return new_user
def update_user(self, user_id, user): if "name" in user: user["name"] = clean.user_name(user["name"]) session = self.get_session() if "id" in user and user_id != user["id"]: raise exception.ValidationError("Cannot change user ID") with session.begin(): user_ref = session.query(User).filter_by(id=user_id).first() if user_ref is None: raise exception.UserNotFound(user_id=user_id) old_user_dict = user_ref.to_dict() user = utils.hash_user_password(user) for k in user: old_user_dict[k] = user[k] new_user = User.from_dict(old_user_dict) for attr in User.attributes: if attr != "id": setattr(user_ref, attr, getattr(new_user, attr)) user_ref.extra = new_user.extra session.flush() return identity.filter_user(user_ref.to_dict(include_extra_dict=True))
def update_user(self, user_id, user): if 'name' in user: user['name'] = clean.user_name(user['name']) session = self.get_session() if 'id' in user and user_id != user['id']: raise exception.ValidationError('Cannot change user ID') with session.begin(): user_ref = session.query(User).filter_by(id=user_id).first() if user_ref is None: raise exception.UserNotFound(user_id=user_id) old_user_dict = user_ref.to_dict() user = utils.hash_user_password(user) for k in user: old_user_dict[k] = user[k] new_user = User.from_dict(old_user_dict) for attr in User.attributes: if attr != 'id': setattr(user_ref, attr, getattr(new_user, attr)) user_ref.extra = new_user.extra session.flush() return identity.filter_user(user_ref.to_dict(include_extra_dict=True))
def update_user(self, user_id, user): if 'name' in user: user['name'] = clean.user_name(user['name']) if 'enabled' in user: user['enabled'] = clean.user_enabled(user['enabled']) session = self.get_session() if 'id' in user and user_id != user['id']: raise exception.ValidationError('Cannot change user ID') with session.begin(): user_ref = self._get_user(session, user_id) old_user_dict = user_ref.to_dict() user = utils.hash_user_password(user) for k in user: old_user_dict[k] = user[k] new_user = User.from_dict(old_user_dict) for attr in User.attributes: if attr != 'id': setattr(user_ref, attr, getattr(new_user, attr)) user_ref.extra = new_user.extra session.flush() return identity.filter_user(user_ref.to_dict(include_extra_dict=True))
def update_user(self, user_id, user): if 'name' in user: user['name'] = clean.user_name(user['name']) session = self.get_session() if 'id' in user and user_id != user['id']: raise exception.ValidationError('Cannot change user ID') # FIXME(henry-nash) Think about how we detect potential name clash # when we move domains with session.begin(): user_ref = session.query(User).filter_by(id=user_id).first() if user_ref is None: raise exception.UserNotFound(user_id=user_id) old_user_dict = user_ref.to_dict() user = utils.hash_user_password(user) for k in user: old_user_dict[k] = user[k] new_user = User.from_dict(old_user_dict) for attr in User.attributes: if attr != 'id': setattr(user_ref, attr, getattr(new_user, attr)) user_ref.extra = new_user.extra session.flush() return identity.filter_user(user_ref.to_dict(include_extra_dict=True))
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) return self.user.create(user)
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) user['enabled'] = clean.user_enabled(user.get('enabled', True)) return identity.filter_user(self.user.create(user))
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) return identity.filter_user(self.user.create(user))
def create_user(self, user_id, user_ref): user = user_ref.copy() user['name'] = clean.user_name(user['name']) user.setdefault('enabled', True) user['enabled'] = clean.user_enabled(user['enabled']) return self.driver.create_user(user_id, user)
def update_user(self, user_id, user): if "name" in user: user["name"] = clean.user_name(user["name"]) return self.user.update(user_id, user)
def create_user(self, user_id, user): user = self._validate_domain(user) user['name'] = clean.user_name(user['name']) user['enabled'] = clean.user_enabled(user.get('enabled', True)) user_ref = self.user.create(user) return self._set_default_domain(identity.filter_user(user_ref))
def update_user(self, user_id, user): if 'name' in user: user['name'] = clean.user_name(user['name']) return self.user.update(user_id, user)
def create_user(self, context, user_id, user_ref): user = user_ref.copy() user['name'] = clean.user_name(user['name']) user.setdefault('enabled', True) user['enabled'] = clean.user_enabled(user['enabled']) return self.driver.create_user(user_id, user)
def create_user(self, user_id, user): user['name'] = clean.user_name(user['name']) unfiltered_user = self.user.create(user) filtered = identity.filter_user(unfiltered_user) return filtered