def lambda_handler(event, context): log.debug("Received event: " + json.dumps(event)) check_auth(event["headers"], config) handle_lambda_proxy_event(event) return { "isBase64Encoded": False, "statusCode": 200, "headers": {"Content-Length": 0}, }
def preloop(self): big_print('Postal Logistics') user = check_auth() if user: big_print('Hi, ' + user['full_name']) self.prompt = '{0}/{1}: '.format(user['role'], user['username']) self.user = User(**user) else: clearConsole() print('Неверные логин или пароль') self.preloop()
def _upload_character(): auth = request.form.get('Auth') if not auth or not check_auth(auth): return authenticate() try: user = request.form.get('user') zipfile = request.files.get('zipfile') lang = request.files.get('lang') saved_dir = os.path.join(INCOMING_DIR, user) if not os.path.isdir(saved_dir): os.makedirs(saved_dir) # Clean the incoming directory for f in os.listdir(saved_dir): f = os.path.join(saved_dir, f) if os.path.isfile(f): os.unlink(f) else: shutil.rmtree(f, True) saved_zipfile = os.path.join(saved_dir, zipfile.filename) zipfile.save(saved_zipfile) logger.info("Get zip file {}".format(zipfile.filename)) from loader import AIMLCharacterZipLoader characters = AIMLCharacterZipLoader.load(saved_zipfile, saved_dir, 'upload') ret, response = True, "Done" for character in characters: character.local = False character.id = '{}/{}'.format(user, character.id) _ret, _response = add_character(character) if not _ret: ret = _ret response = _response os.remove(saved_zipfile) return Response(json_encode({ 'ret': ret, 'response': response }), mimetype="application/json") except Exception as ex: return Response(json_encode({ 'ret': False, 'response': str(ex) }), mimetype="application/json")
def delete_event(event_id): event = Event.query.filter_by(id=event_id).one_or_none() if event is None: abort(404) host = event.host if host is None: # in case of host not existing anymore if check_auth(permission='delete:events'): db.session.delete(event) db.session.commit() return jsonify({'success': True}), 200 else: abort(403) if get_current_member_object() == host: db.session.delete(event) db.session.commit() return jsonify({'success': True}), 200 else: if check_auth(permission='delete:events'): db.session.delete(event) db.session.commit() return jsonify({'success': True}), 200 else: abort(403)
def LiveStreamMenu(): Log("auth level = %s" % auth.check_auth()) if auth.check_auth() != False: oc = ObjectContainer(title2 = "Live Streams", view_group= "InfoList") live_stream_data = HTML.ElementFromURL(LIVE_STREAMS_URL) for live_streams in live_stream_data.xpath(".//a[@class='warningMessage']"): live_streams_str = HTML.StringFromElement(live_streams) live_streams_id = (re.findall('ids=([0-9]{1,6})', live_streams_str))[0] live_streams_json_query = LIVE_DATA_JSON_URL + "?vid=" + live_streams_id live_streams_json = JSON.ObjectFromURL(live_streams_json_query) try: live_streams_decrypted = getMediaDecryptedPathString( live_streams_json['result']['services']['videoURL'], "LIVE") except: live_streams_decrypted = "" if live_streams_decrypted[:4] == "rtmp": live_streams_rtmp_params = getStreamRTMPParamsFromString(live_streams_decrypted) oc.add(VideoClipObject( key = RTMPVideoURL( url = live_streams_rtmp_params['rtmpServer'], clip = live_streams_rtmp_params['playpath'], swf_url = SWF_PLAYER_URL, live = True), rating_key = live_streams_id, thumb = Resource.ContentsOfURLWithFallback(url=live_streams_json['result']['menu']['details']['imageURL'], fallback=ICON), title = live_streams_json['result']['menu']['details']['title'], summary = live_streams_json['result']['menu']['details']['description'])) else: oc = ObjectContainer(header = "Login details required", message = "Please check that you have entered your correct email and password in Preferences.") return oc
def login(): login_form = LoginForm(request.form) if login_form.validate(): if check_auth( login_form.username.data, login_form.password.data, ): login_user(User(login_form.username.data)) else: flash('Wrong username or password') else: flash('Please fill out all fields') return redirect(url_for('index'))
def _batch_chat(): auth = request.form.get('Auth') if not auth or not check_auth(auth): return authenticate() questions = request.form.get('questions') questions = json.loads(questions) session = request.form.get('session') lang = request.form.get('lang', 'en') responses = [] for idx, question in questions: response, ret = ask(str(question), lang, session) responses.append((idx, response, ret)) return Response(json_encode({'ret': 0, 'response': responses}), mimetype="application/json")
def login(): # Login interface for non PubCookie setups. log_access('login') # Is form submitted? if request.method == 'POST': log_access('login', 'posted form') if auth.check_auth(request.form['username'], request.form['password']): return redirect(url_for('home')) # Is it a PubCookie setup? if not config.USES_PUBCOOKIE: log_access('login', 'not using pubcookie') return render_template('login.html') # Show the form. else: log_access('login', 'using pubcookie only, error message') return render_template('pubcookie_only.html', uwnetid=request.environ['REMOTE_USER'] if 'REMOTE_USER' in request.environ else None)
def login(): """ This view authenticates the user based on the LoginForm """ form = users.LoginForm(request.form) if request.method == 'POST' and form.validate(): # if the authentication is valid the user instance is returned user = auth.check_auth(form.email.data, util.set_password(form.password.data)) if user: # register the user authentication data in the session # so we can retrieve later during the requires_auth session['user'] = user.email session['user_auth'] = user.password return redirect('/user') return render_template('login.html', form=form)
def chat2(): auth = request.form.get('Auth') if not auth or not check_auth(auth): return authenticate() id = request.form.get('botid') questions = request.form.get('questions') questions = json.loads(questions) session = request.form.get('session') lang = request.form.get('lang', 'en') responses = [] for idx, question in questions: response, ret = ask(id, str(question), lang, session) responses.append((idx, response, ret)) return Response(json_encode({'ret': 0, 'response': responses}), mimetype="application/json")
def login(): """Responds to /auth/login (GET request) by raising a CredentialsRequired Exception. A valid POST request login a user and returns a token in the JSON response returned. """ if request.method == "GET": raise CredentialsRequired() username = request.form.get("username") password = request.form.get("password") if auth.check_auth(username, password): return { "message": [auth.MESSAGES["login"], {"available endpoints": app.config.get("AVAILABLE_ENDPOINTS")}], "token": auth.tokenize(username, password), } else: raise AuthenticationFailed()
def login(): """Login using a POST request, else prompt for credentials """ if request.method == 'GET': raise CredentialsRequired() # handle POST login username = request.form.get('username') password = request.form.get('password') if auth.check_auth(username, password): return { 'message': [ auth.SERVICE_MESSAGES['login'], { 'available endpoints': app.config.get('AVAILABLE_ENDPOINTS') } ], 'token': auth.generate_token(username, password) } else: raise AuthenticationFailed()
def login(): '''Responds to /auth/login (GET request) by raising a CredentialsRequired Exception. A valid POST request login a user and returns a token in the JSON response returned. ''' if request.method == "GET": raise CredentialsRequired() username = request.form.get("username") password = request.form.get("password") if auth.check_auth(username, password): return { "message": [ auth.MESSAGES["login"], { "available endpoints": app.config.get('AVAILABLE_ENDPOINTS') } ], "token": auth.tokenize(username, password) } else: raise AuthenticationFailed()
def send_csvdata(): auth = request.form.get('Auth') if not auth or not check_auth(auth): return authenticate() try: id = request.form.get('botid') ssid = request.form.get('ssid') character = get_character(id, True) # make sure the character exists zipfile = request.files.get('csvzipfile') # Clean the incoming directory for f in os.listdir(character.incoming_dir): f = os.path.join(character.incoming_dir, f) if os.path.isfile(f): os.unlink(f) else: shutil.rmtree(f, True) saved_zipfile = os.path.join(character.incoming_dir, zipfile.filename) zipfile.save(saved_zipfile) with ZipFile(saved_zipfile) as f: f.extractall(character.incoming_dir) character.set_csv_dir(os.path.join(character.incoming_dir, ssid)) logger.info("Get zip file {}".format(zipfile.filename)) return Response(json_encode({ 'ret': True, 'response': "Get zip file {}".format(zipfile.filename) }), mimetype="application/json") except Exception as ex: return Response(json_encode({ 'ret': False, 'response': str(ex) }), mimetype="application/json")
def login(): email = request.form['email'] password = request.form['password'] check_auth(email, password) return render_template('home.html')
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys import auth def printpdf(): print "Content-Type: application/pdf" print f = open('howtostart2.pdf', "rb") for data in f: sys.stdout.write(data) f.close() if __name__ == '__main__': # check auth a = auth.check_auth() if a == None: auth.html("please login.") # set reading flag d = a.getdata() d.setdefault("howto", 1) d["howto"] = 1 a.setdata(d) # print PDF file printpdf() sys.exit(0)