Skip to content

Commit

Permalink
enable auth flag in project_router
Browse files Browse the repository at this point in the history
  • Loading branch information
jayeshhireox committed Feb 21, 2025
1 parent c53475f commit 4b6539a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion python/mdvtools/project_router.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from flask import Flask, Response, request, jsonify, session, redirect, url_for
from typing import Dict, Any, Callable, Tuple
import re
Expand Down Expand Up @@ -86,6 +87,9 @@ class ProjectBlueprint_v2:
# Class-level constant for the timestamp update interval
TIMESTAMP_UPDATE_INTERVAL = timedelta(hours=1)

# Normalize ENABLE_AUTH to a boolean
AUTH_ENABLED = os.getenv("ENABLE_AUTH", "true").strip().lower() in {"1", "yes", "true"}

@staticmethod
def register_app(app: Flask) -> None:
@app.route(
Expand All @@ -100,7 +104,7 @@ def project_route(project_id: str, subpath: str):
It will look up the project_id in ProjectBlueprint_v2.blueprints and call the method with the given subpath.
The ProjectBlueprint_v2 instance is responsible for routing the request to the correct method etc.
"""
if not ProjectBlueprint_v2.is_authenticated():
if ProjectBlueprint_v2.AUTH_ENABLED and not ProjectBlueprint_v2.is_authenticated():
return redirect(url_for('login_dev'))

if project_id in ProjectBlueprint_v2.blueprints:
Expand Down

0 comments on commit 4b6539a

Please sign in to comment.