Python web.seeother() Examples
The following are 30
code examples of web.seeother().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
web
, or try the search function
.
Example #1
Source File: social.py From INGInious with GNU Affero General Public License v3.0 | 6 votes |
def process_callback(self, auth_id): auth_method = self.user_manager.get_auth_method(auth_id) if not auth_method: raise web.notfound() auth_storage = self.user_manager.session_auth_storage().setdefault(auth_id, {}) user = auth_method.callback(auth_storage) if user and auth_storage.get("method", "") == "signin": if not self.user_manager.bind_user(auth_id, user): raise web.seeother("/signin?binderror") elif user and auth_storage.get("method", "") == "share": submission = self.submission_manager.get_submission(auth_storage["submissionid"], True) if submission: course = self.course_factory.get_course(submission["courseid"]) task = course.get_task(submission["taskid"]) auth_method.share(auth_storage, course, task, submission, self.user_manager.session_language()) else: raise web.notfound() else: raise web.seeother("/signin?callbackerror") raise web.seeother(auth_storage.get("redir_url", "/"))
Example #2
Source File: lti.py From INGInious with GNU Affero General Public License v3.0 | 6 votes |
def GET(self): """ Checks if user is authenticated and calls POST_AUTH or performs login and calls GET_AUTH. Otherwise, returns the login template. """ data = self.user_manager.session_lti_info() if data is None: raise web.notfound() try: course = self.course_factory.get_course(data["task"][0]) if data["consumer_key"] not in course.lti_keys().keys(): raise Exception() except: return self.template_helper.get_renderer().lti_bind(False, "", None, "Invalid LTI data") user_profile = self.database.users.find_one({"ltibindings." + data["task"][0] + "." + data["consumer_key"]: data["username"]}) if user_profile: self.user_manager.connect_user(user_profile["username"], user_profile["realname"], user_profile["email"], user_profile["language"]) if self.user_manager.session_logged_in(): raise web.seeother(self.app.get_homepath() + "/lti/task") return self.template_helper.get_renderer().lti_login(False)
Example #3
Source File: authentication.py From riXSS with GNU General Public License v2.0 | 6 votes |
def has_obj_permission(obj, obj_id, url="/login", exception=False): def has_permission(_obj=obj, _obj_id=obj_id): user_id = web.cookies().get('user_id') if not user_id: return False if exception: #Exception only for view public modules. if int(get_detail(XSS_CORE, obj_id, 'owner')) == 0: return True if not is_owner(user_id=user_id, obj_id=_obj_id, obj_type=_obj): return False return True def decorator(func): def _decorator(): if has_permission(obj, obj_id): return func else: def return_a_error(): return web.seeother(url) return return_a_error return _decorator() return decorator
Example #4
Source File: authentication.py From riXSS with GNU General Public License v2.0 | 6 votes |
def authentication(uid=None): def has_permission(): cookies = web.cookies() token, user_id = cookies.get('token'), cookies.get('user_id') if uid and not uid == user_id: return False if not token or not user_id: return False if not auth_check(user_id, token): return False return True def decorator(func): def _decorator(): if has_permission(): return func else: def return_a_error(): return web.seeother('/login') return return_a_error return _decorator() return decorator
Example #5
Source File: auth.py From netflix-proxy with MIT License | 6 votes |
def POST(self): form = DDNSIndex.ddns_add_form() if not form.validates(): flash('error', 'form validation failed') raise web.seeother('/ddns') web.debug('Removing domain=%s' % form['domain'].value) web.header('Content-Type', 'text/html') db_result = db.delete('DDNS', where="user_id=%s AND domain='%s'" % (session.user['ID'], form['domain'].value)) web.debug('db.delete: %s' % db_result) flash('success', '%s removed' % form['domain'].value) return web.seeother('/ddns') # Adds a wsgi callable for uwsgi
Example #6
Source File: utils.py From rucio with Apache License 2.0 | 6 votes |
def oidc_auth(account, issuer): """ Open ID Connect Login :param account: Rucio account string :param issuer: issuer key (e.g. xdc, wlcg) as in the idpsecrets.json file :returns: rendered final page or a page with error message """ if not account: account = 'webui' if not issuer: return RENDERER.problem("Please provide IdP issuer.") kwargs = {'audience': None, 'auth_scope': None, 'issuer': issuer.lower(), 'auto': True, 'polling': False, 'refresh_lifetime': None, 'ip': None, 'webhome': ctx.realhome + '/oidc_final'} auth_url = auth.get_auth_oidc(account, **kwargs) if not auth_url: return RENDERER.problem("It was not possible to get the OIDC authentication url from the Rucio auth server. " + "In case you provided your account name, make sure it is known to Rucio.") # NOQA: W503 return seeother(auth_url)
Example #7
Source File: utils.py From INGInious with GNU Affero General Public License v3.0 | 6 votes |
def GET(self, *args, **kwargs): """ Checks if user is authenticated and calls GET_AUTH or performs logout. Otherwise, returns the login template. """ if self.user_manager.session_logged_in(): if not self.user_manager.session_username() and not self.__class__.__name__ == "ProfilePage": raise web.seeother("/preferences/profile") if not self.is_lti_page and self.user_manager.session_lti_info() is not None: #lti session self.user_manager.disconnect_user() return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods()) return self.GET_AUTH(*args, **kwargs) elif self.preview_allowed(*args, **kwargs): return self.GET_AUTH(*args, **kwargs) else: error = '' if "binderror" in web.input(): error = _("An account using this email already exists and is not bound with this service. " "For security reasons, please log in via another method and bind your account in your profile.") if "callbackerror" in web.input(): error = _("Couldn't fetch the required information from the service. Please check the provided " "permissions (name, email) and contact your INGInious administrator if the error persists.") return self.template_helper.get_renderer().auth(self.user_manager.get_auth_methods(), error)
Example #8
Source File: cosa_nostra.py From cosa-nostra with GNU General Public License v3.0 | 6 votes |
def POST(self): if not 'user' in session or session.user is None: f = register_form() return render.login(f) i = web.input(id=None, description=None) cluster_id = i.id if cluster_id is None: return render.error("No cluster id specified.") if not cluster_id.isdigit(): return render.error("Invalid number.") cluster_id = int(cluster_id) desc = i.description vars = {"id":cluster_id} db = open_db() db.update('clusters', vars=vars, where="id = $id", description=desc) raise web.seeother("/view_cluster?id=%d" % cluster_id) #-----------------------------------------------------------------------
Example #9
Source File: auth.py From netflix-proxy with MIT License | 6 votes |
def POST(self): login_form = self.get_login_form() if not login_form.validates(): flash('error', 'form validation failed') return render.login(login_form) username = login_form['username'].value password = login_form['password'].value user = validate_user(username,password) if user: session.user = user web.debug(web.config.session_parameters) flash('success', """you are now logged in, "Add" to authorize %s""" % get_client_public_ip()) raise web.seeother('/') else: session.user = None flash('error', 'login failed for user %s' % username) raise web.seeother('/login') return render.login(login_form)
Example #10
Source File: auth.py From netflix-proxy with MIT License | 5 votes |
def GET(self): ipaddr = get_client_public_ip() web.config.session_parameters['cookie_domain'] = web.ctx.environ['HTTP_HOST'] try: if session.user: raise web.seeother('/') else: flash('success', 'welcome, please login to authorize %s' % ipaddr) return render.login(self.get_login_form()) except Exception as e: web.debug(traceback.print_exc()) flash('success', 'welcome, please login to authorize %s' % ipaddr) return render.login(self.get_login_form())
Example #11
Source File: cosa_nostra.py From cosa-nostra with GNU General Public License v3.0 | 5 votes |
def GET(self): session.user = None del session.user return web.seeother("/") #-----------------------------------------------------------------------
Example #12
Source File: cosa_nostra.py From cosa-nostra with GNU General Public License v3.0 | 5 votes |
def POST(self): i = web.input(username="", password="") if i.username == "" or i.password == "": return render.error("Invalid username or password") elif i.username != CN_USER or sha1(i.password).hexdigest() != CN_PASS: return render.error("Invalid username or password") session.user = i.username return web.seeother("/") #-----------------------------------------------------------------------
Example #13
Source File: __init__.py From opennumber with GNU General Public License v3.0 | 5 votes |
def __init__(self, url, absolute=False): status = '303 See Other' newloc = url home = web.ctx.environ['HTTP_ORIGIN'] newloc = urlparse.urljoin(home, url) logger.info('seeother: %s', newloc) headers = { 'Content-Type': 'text/html', 'Location': newloc } web.webapi.HTTPError.__init__(self, status, headers, "") pass
Example #14
Source File: smcom.py From asm3 with GNU General Public License v3.0 | 5 votes |
def go_smcom_my(dbo): """ Goes to the my account page for this database """ raise web.seeother(smcom_client.get_my_url(dbo.database))
Example #15
Source File: auth.py From netflix-proxy with MIT License | 5 votes |
def POST(self): form = DDNSIndex.ddns_add_form() if not form.validates(): flash('error', 'form validation failed') raise web.seeother('/ddns') web.debug('Adding domain=%s' % form['domain'].value) web.header('Content-Type', 'text/html') db_result = db.insert('DDNS', user_id=session.user['ID'], domain=form['domain'].value) web.debug('db.insert: %s' % db_result) flash('success', 'succesfully added %s' % form['domain'].value) return web.seeother('/ddns')
Example #16
Source File: site.py From iOS-private-api-scanner with GNU General Public License v2.0 | 5 votes |
def POST(self): x = web.input(myfile={}) filedir = '/Users/sngTest/armingli/upload/' # change this to the directory you want to store the file in. if 'myfile' in x: # to check if the file-object is created filepath=x.myfile.filename.replace('\\','/') # replaces the windows-style slashes with linux ones. filename=filepath.split('/')[-1] # splits the and chooses the last part (the filename with extension) fout = open(filedir +'/'+ filename,'w') # creates the file where the uploaded file should be stored fout.write(x.myfile.file.read()) # writes the uploaded file to the newly created file. fout.close() # closes the file, upload complete. #scanapp.stringsAPP(filename) raise web.seeother('/suc')
Example #17
Source File: main.py From NeuronBlocks with MIT License | 5 votes |
def GET(self): raise web.seeother('/mv')
Example #18
Source File: utils.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def GET_AUTH(self): # pylint: disable=arguments-differ """ GET request """ raise web.seeother('/preferences/profile')
Example #19
Source File: websvr.py From nmeta with Apache License 2.0 | 5 votes |
def GET(self): raise web.seeother('/static/index1234.html')
Example #20
Source File: auth.py From netflix-proxy with MIT License | 5 votes |
def GET(self): session.user = None session.already_authorized = None session.auth_ip_count = None session.kill() raise web.seeother('/login')
Example #21
Source File: auth.py From netflix-proxy with MIT License | 5 votes |
def GET(self): try: if 'user' in session: domains = db.query('SELECT * FROM DDNS WHERE user_id=$user_id', vars={'user_id': session.user['ID']}) return render.ddns(domains, DDNSIndex.ddns_add_form()) else: web.seeother('/login') except Exception as e: flash('error', 'Please update the database schema. See README for details.') web.debug(traceback.print_exc()) raise web.seeother('/')
Example #22
Source File: websvr.py From nmeta with Apache License 2.0 | 5 votes |
def GET(self): raise web.seeother('/static/index80.html')
Example #23
Source File: websvr.py From nmeta with Apache License 2.0 | 5 votes |
def GET(self): raise web.seeother('/static/index.html')
Example #24
Source File: auth.py From netflix-proxy with MIT License | 5 votes |
def GET(self): ipaddr = get_client_public_ip() is_ipv4 = web.net.validipaddr(ipaddr) is_ipv6 = web.net.validip6addr(ipaddr) if AUTO_AUTH: if ipaddr: web.debug('AUTO_AUTH: %s' % ipaddr) if is_ipv4: result = run_ipt_cmd(ipaddr, 'I') if is_ipv6: result = run_ipt6_cmd(ipaddr, 'I') web.debug('iptables_update: %s' % [result]) if result[0] == 0: flash('success', 'automatically authorized %s' % ipaddr) return render.redirect(get_redirect_page()) else: flash('error', 'unable to automatically authorize %s' % ipaddr) raise web.seeother('/add') else: flash('error', 'something went wrong, please login to authorize') raise web.seeother('/') else: try: if session.user: ipaddrs = get_ipaddrs() if len(ipaddrs) == 0: return web.seeother('/add') return render.index(ipaddrs) except Exception as e: web.debug(traceback.print_exc()) raise web.seeother('/login')
Example #25
Source File: google_auth.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def share(self, auth_storage, course, task, submission, language): raise web.seeother("https://plus.google.com/share?url=" + web.ctx.home + "/course/" + course.get_id() + "/" + task.get_id())
Example #26
Source File: course.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def POST_AUTH(self, courseid): # pylint: disable=arguments-differ """ POST request """ course = self.get_course(courseid) user_input = web.input() if "unregister" in user_input and course.allow_unregister(): self.user_manager.course_unregister_user(course, self.user_manager.session_username()) raise web.seeother(self.app.get_homepath() + '/mycourses') return self.show_page(course)
Example #27
Source File: course.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def handle_course_unavailable(app_homepath, template_helper, user_manager, course): """ Displays the course_unavailable page or the course registration page """ reason = user_manager.course_is_open_to_user(course, lti=False, return_reason=True) if reason == "unregistered_not_previewable": username = user_manager.session_username() user_info = user_manager.get_user_info(username) if course.is_registration_possible(user_info): raise web.seeother(app_homepath + "/register/" + course.get_id()) return template_helper.get_renderer(use_jinja=True).course_unavailable(reason=reason)
Example #28
Source File: submission.py From INGInious with GNU Affero General Public License v3.0 | 5 votes |
def POST_AUTH(self, submissionid): # pylint: disable=arguments-differ course, task, submission = self.fetch_submission(submissionid) is_admin = self.user_manager.has_admin_rights_on_course(course) webinput = web.input() if "replay" in webinput and is_admin: self.submission_manager.replay_job(task, submission) elif "replay-copy" in webinput: # Authorized for tutors self.submission_manager.replay_job(task, submission, True) web.seeother(self.app.get_homepath() + "/course/" + course.get_id() + "/" + task.get_id()) elif "replay-debug" in webinput and is_admin: self.submission_manager.replay_job(task, submission, True, "ssh") web.seeother(self.app.get_homepath() + "/course/" + course.get_id() + "/" + task.get_id()) return self.page(course, task, submission)
Example #29
Source File: main.py From jingwei with MIT License | 5 votes |
def POST(self): input = web.input() raise web.seeother('/?query=%s&tagrel=1' % input.tags)
Example #30
Source File: common.py From BaoTa-Panel with GNU General Public License v3.0 | 5 votes |
def checkAddressWhite(self): token = self.GetToken(); if not token: raise web.seeother('/login'); if not web.ctx.ip in token['address']: raise web.seeother('/login'); #检查IP限制