def authenticate(self, username, password): """ Check username and password - either from local database, LDAP, or some other external authentication server. Return username on success, None on failure. """ if not username or not password: return None # old user user = get_userstore().getUser(username) if user: authentication_name = self.auth_store.get_authentication_method(user.authentication_key) auth_module = self._get_auth_module(authentication_name) if auth_module: auth_username = auth_module.authenticate(username, password) if auth_username: User.update_last_login(auth_username) return auth_username return None # new user for x in conf.authentication_order: auth_module = self._get_auth_module(x) if auth_module: auth_username = auth_module.authenticate(username, password) if auth_username: User.update_last_login(auth_username) return auth_username return None
def authenticate(self, username, password): """ Check username and password - either from local database, LDAP, or some other external authentication server. Return username on success, None on failure. """ if not username or not password: return None # old user user = get_userstore().getUser(username) if user: authentication_name = self.auth_store.get_authentication_method( user.authentication_key) auth_module = self._get_auth_module(authentication_name) if auth_module: auth_username = auth_module.authenticate(username, password) if auth_username: User.update_last_login(auth_username) return auth_username return None # new user for x in conf.authentication_order: auth_module = self._get_auth_module(x) if auth_module: auth_username = auth_module.authenticate(username, password) if auth_username: User.update_last_login(auth_username) return auth_username return None
def setUp(self): userObj = User() userObj.id = 30 userObj.username = '******' self.projectObj = Project(24, 'storageauthtest', 'Storage auth testing', 'Desc', userObj.id, None, author = userObj) conf.use_test_db(True) self.load_fixtures() self.store = CQDEUserGroupStore(self.projectObj.id) self.store.remove_group('Owners') self.store.remove_group('Public contributors') self.store.remove_group('Public viewers')
def _get_user(self, req): user = User() user.username = req.args.get('username') user.mail = req.args.get('email') user.givenName = req.args.get('first') user.lastName = req.args.get('last') user.password = self._generate_password() user.mobile = req.args.get('mobile') user.createIcon(req.args.get('icon')) # Empty makes it default (Local users) user.organization_keys = [] return user
def upgrade(self): if self.applied(): print "Migration already applied".rjust(12) return True org_store = CQDEOrganizationStore.instance() user = User() organization_ids = org_store.get_organization_keys(user, LOCAL) if not organization_ids or len(organization_ids) > 1: print "Local organization was not found!" return False local_organization_id = organization_ids[0] queries = [ """ INSERT INTO user_organization (user_key, organization_key) SELECT user_id, {organization_id} FROM user WHERE user_id NOT IN (SELECT user_key FROM user_organization) AND authentication_key IN (SELECT id FROM authentication WHERE method = '{method}') """.format(organization_id=local_organization_id, method=LOCAL) ] return self.manager.db_upgrade(queries)
def setUp(self): userObj = User() userObj.id = 30 userObj.username = '******' self.projectObj = Project(24, 'storageauthtest', 'Storage auth testing', 'Desc', userObj.id, None, author=userObj) conf.use_test_db(True) self.load_fixtures() self.store = CQDEUserGroupStore(self.projectObj.id) self.store.remove_group('Owners') self.store.remove_group('Public contributors') self.store.remove_group('Public viewers')