def _check_user_exist(self, session, user_id): auth = CoreAuthenticator(settings.auth_server_url) resp = auth.check_user_exist(session.session_id, user_id) if resp['status'] == 'ok': if resp['exist'] == True: pass else: raise UserNotExists('User %s not exists' % user_id) else: raise UserCheckingError(resp.get('message'))
def decroated(self, data, curs): auth = CoreAuthenticator(settings.auth_server_url) session_id = data['session_id'] custom_actor_info = data.pop('custom_actor_info', None) resp = auth.check_access(session_id, 'billing', method.__name__) if resp.get('status') == 'ok': session = Session(session_id, '%s' % resp['environment_id'], '%s' % resp['user_id']) if resp.get('access') == 'granted': try: result = method(self, data, session, curs=curs) except Exception, e: data['environment_id'] = session.environment_id _add_log_info(data, session, custom_actor_info) raise e else: result = {'status': 'error', 'code': error_code.HELIX_AUTH_ERROR, 'message': 'Access denied'} _add_log_info(data, session, custom_actor_info)
def decroated(self, data, curs): auth = CoreAuthenticator(settings.auth_server_url) session_id = data['session_id'] custom_actor_info = data.pop('custom_actor_info', None) resp = auth.check_access(session_id, 'tariff', method.__name__) if resp.get('status') == 'ok': session = Session(session_id, '%s' % resp['environment_id'], '%s' % resp['user_id']) if resp.get('access') == 'granted': try: result = method(self, data, session, curs=curs) except Exception, e: data['environment_id'] = session.environment_id _add_log_info(data, session, custom_actor_info) raise e else: result = { 'status': 'error', 'code': error_code.HELIX_AUTH_ERROR, 'message': 'Access denied' } _add_log_info(data, session, custom_actor_info)
def logout(self, data): auth = CoreAuthenticator(settings.auth_server_url) resp = auth.logout(data) return resp