Famcy/_util_/_fmanager.py
def register_csrf(self, app):
		"""
		This is the security method to 
		prevent csrf. Prereq: MainBlueprint
		needs to be defined
		"""
		def csrf_token():
			"""
			Generate a token string from bytes arrays. The token in the session is user
			specific.
			"""
			if "_csrf_token" not in session:
				session["_csrf_token"] = os.urandom(128)
			return hmac.new(app.secret_key, session["_csrf_token"],
					digestmod=sha1).hexdigest()

		def check_csrf_token():
			"""Checks that token is correct, aborting if not"""
			if request.method in ("GET",): # not exhaustive list
				return
			token = request.form.get("csrf_token")
			print(request.form)
			if token is None:
				app.logger.warning("Expected CSRF Token: not present")
				abort(400)
			if not safe_str_cmp(token, csrf_token()):
				app.logger.warning("CSRF Token incorrect")
				abort(400)

		app.template_global('csrf_token')(csrf_token)
		app.before_request(check_csrf_token)

		This is the security method to 
		prevent csrf. Prereq: MainBlueprint
		needs to be defined
		
This is the security method to
prevent csrf. Prereq: MainBlueprint
needs to be defined
This is the security method to prevent csrf . Prereq : MainBlueprint needs to be defined
def register_csrf(self, app):
		def csrf_token():
			if "_csrf_token" not in session:
				session["_csrf_token"] = os.urandom(128)
			return hmac.new(app.secret_key, session["_csrf_token"],
					digestmod=sha1).hexdigest()
		def check_csrf_token():
			if request.method in ("GET",): 
				return
			token = request.form.get("csrf_token")
			print(request.form)
			if token is None:
				app.logger.warning("Expected CSRF Token: not present")
				abort(400)
			if not safe_str_cmp(token, csrf_token()):
				app.logger.warning("CSRF Token incorrect")
				abort(400)
		app.template_global('csrf_token')(csrf_token)
		app.before_request(check_csrf_token)
def register_csrf ( self , app ) : def csrf_token ( ) : """
			Generate a token string from bytes arrays. The token in the session is user
			specific.
			""" if "_csrf_token" not in session : session [ "_csrf_token" ] = os . urandom ( 128 ) return hmac . new ( app . secret_key , session [ "_csrf_token" ] , digestmod = sha1 ) . hexdigest ( ) def check_csrf_token ( ) : """Checks that token is correct, aborting if not""" if request . method in ( "GET" , ) : return token = request . form . get ( "csrf_token" ) print ( request . form ) if token is None : app . logger . warning ( "Expected CSRF Token: not present" ) abort ( 400 ) if not safe_str_cmp ( token , csrf_token ( ) ) : app . logger . warning ( "CSRF Token incorrect" ) abort ( 400 ) app . template_global ( 'csrf_token' ) ( csrf_token ) app . before_request ( check_csrf_token )
This is the security method to
prevent csrf.
This is the security method to prevent csrf .
"""
		This is the security method to 
		prevent csrf. Prereq: MainBlueprint
		needs to be defined
		""" """
			Generate a token string from bytes arrays. The token in the session is user
			specific.
			""" """Checks that token is correct, aborting if not""" # not exhaustive list
self
app