diff --git a/jon/__init__.py b/jon/__init__.py
index 7766f92..01498d4 100644
--- a/jon/__init__.py
+++ b/jon/__init__.py
@@ -1,9 +1,11 @@
import inspect
import json
+import sys
from flask import Flask, render_template
from . import (
+ auth,
db,
entry,
inventory,
@@ -21,6 +23,10 @@ def create_app():
db.init_app(app)
+ @app.before_request
+ def before_req_fun():
+ return auth.before_request()
+
@app.context_processor
def utility_processor():
return dict(inspect.getmembers(template_utils, inspect.isfunction))
@@ -28,8 +34,11 @@ def create_app():
app.register_blueprint(location.bp)
app.register_blueprint(inventory.bp)
app.register_blueprint(entry.bp)
+ app.register_blueprint(auth.auth)
@app.route("/")
def index():
return render_template("index.html")
+ print("Jon started. Token: %s" % auth.ACCESS_TOKEN, file=sys.stderr)
+
return app
diff --git a/jon/auth.py b/jon/auth.py
new file mode 100644
index 0000000..b843f2d
--- /dev/null
+++ b/jon/auth.py
@@ -0,0 +1,44 @@
+from flask import Blueprint, request, redirect, make_response
+from . import db
+import random
+import string
+
+auth = Blueprint('auth', __name__)
+
+ACCESS_TOKEN = ''.join(random.choice(string.ascii_lowercase) for i in range(64))
+
+ERROR_TEXT = """
+ For security-reasons we must make sure you are the person who executed jon :D
+