aboutsummaryrefslogtreecommitdiff
path: root/gn_auth
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-08-07 12:16:12 +0300
committerFrederick Muriuki Muriithi2023-08-07 12:16:12 +0300
commitaf9ab012a3763e3046d8c42a8af8fd5c06e3df04 (patch)
treee6e5d4e103748d4af55004f9f9e89161033760fb /gn_auth
parent61d1c03170d8f22ecd67051df56c2a66e83eb502 (diff)
downloadgn-auth-af9ab012a3763e3046d8c42a8af8fd5c06e3df04.tar.gz
Add routes to the application
Diffstat (limited to 'gn_auth')
-rw-r--r--gn_auth/__init__.py10
-rw-r--r--gn_auth/misc_views.py18
2 files changed, 28 insertions, 0 deletions
diff --git a/gn_auth/__init__.py b/gn_auth/__init__.py
index 4ef2892..7d9228d 100644
--- a/gn_auth/__init__.py
+++ b/gn_auth/__init__.py
@@ -6,6 +6,11 @@ from flask import Flask
from . import settings
+from gn_auth.auth import oauth2
+from gn_auth.misc_views import misc
+
+from gn_auth.auth.authentication.oauth2.server import setup_oauth2_server
+
class ConfigurationError(Exception):
"""Raised in case of a configuration error."""
@@ -61,5 +66,10 @@ def create_app(config: dict = {}) -> Flask:
check_mandatory_settings(app)
setup_logging_handlers(app)
+ setup_oauth2_server(app)
+
+ ## Blueprints
+ app.register_blueprint(misc, url_prefix="/")
+ app.register_blueprint(oauth2, url_prefix="/auth")
return app
diff --git a/gn_auth/misc_views.py b/gn_auth/misc_views.py
new file mode 100644
index 0000000..bd2ad62
--- /dev/null
+++ b/gn_auth/misc_views.py
@@ -0,0 +1,18 @@
+"""
+Miscellaneous top-level views that have nothing to do with the application's
+functionality.
+"""
+from pathlib import Path
+
+from flask import Blueprint
+
+misc = Blueprint("misc", __name__)
+
+@misc.route("/version")
+def version():
+ """Get the application's version information."""
+ version_file = Path("VERSION.txt")
+ if version_file.exists():
+ with open(version_file, encoding="utf-8") as verfl:
+ return verfl.read().strip()
+ return "0.0.0"