aboutsummaryrefslogtreecommitdiff
path: root/app/auth.py
diff options
context:
space:
mode:
authorParker <contact@pkrm.dev>2024-02-25 02:15:31 -0600
committerParker <contact@pkrm.dev>2024-02-25 02:15:31 -0600
commit0ea4abca33363f0bbdffa181b60beefc247774fa (patch)
tree0a6dcd17d5a6d7d9fdb1395548fb33cedf559f2c /app/auth.py
parentf3ff78bc8db5d8e7938407a62d56410cc72ce3a7 (diff)
Creation
Diffstat (limited to 'app/auth.py')
-rw-r--r--app/auth.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/auth.py b/app/auth.py
new file mode 100644
index 0000000..c9fe89b
--- /dev/null
+++ b/app/auth.py
@@ -0,0 +1,16 @@
+from flask_httpauth import HTTPTokenAuth
+import sqlalchemy
+
+from db import engine
+
+
+auth = HTTPTokenAuth(scheme='Bearer')
+
+@auth.verify_token
+def verify_token(token):
+ try:
+ with engine.begin() as conn:
+ token = conn.execute(sqlalchemy.text('SELECT * FROM accounts WHERE account_name = :account_name'), [{'account_name': token}]).fetchone()
+ return token[0]
+ except TypeError:
+ return False \ No newline at end of file