Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/single_app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
EXECUTOR_TYPE = 'thread'
EXECUTOR_MAX_WORKERS = 30
SESSION_TYPE = 'filesystem'
VERSION = "0.242.072"
VERSION = "0.242.075"

SESSION_COOKIE_SAMESITE = os.getenv('SESSION_COOKIE_SAMESITE', 'Lax')
SESSION_COOKIE_HTTPONLY = os.getenv('SESSION_COOKIE_HTTPONLY', 'true').lower() != 'false'
Expand Down
36 changes: 29 additions & 7 deletions application/single_app/functions_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

import base64
import json
import re

from config import *
from functions_appinsights import log_event
try:
from functions_appinsights import log_event
except Exception:
def log_event(message, extra=None, level=None, exceptionTraceback=False):
return None
Comment on lines +8 to +12

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there an issue trying to import log_event? Why wrap it in the try block?

from functions_settings import *
from functions_debug import debug_print

Expand Down Expand Up @@ -331,7 +336,23 @@ def get_valid_access_token_for_plugins(scopes=None):
"error_code": error_code,
"error_description": error_desc
}



def _sanitize_video_indexer_auth_log_value(value):
text = str(value)
text = re.sub(
r'([?&]accessToken=)[^&\s\'"<>]+',
r'\1[REDACTED]',
text,
flags=re.IGNORECASE,
)
return re.sub(
r'([\'"]?accessToken[\'"]?\s*[:=]\s*[\'"]?)[^,\'"\s}&]+',
r'\1[REDACTED]',
text,
flags=re.IGNORECASE,
)

def get_video_indexer_account_token(settings, video_id=None):
"""
Get Video Indexer access token using managed identity authentication.
Expand Down Expand Up @@ -435,28 +456,29 @@ def get_video_indexer_managed_identity_token(settings, video_id=None):
debug_print(f"[VIDEO INDEXER AUTH] ARM API response status: {resp.status_code}")

if resp.status_code != 200:
debug_print(f"[VIDEO INDEXER AUTH] ARM API response text: {resp.text}")
debug_print(f"[VIDEO INDEXER AUTH] ARM API response text: {_sanitize_video_indexer_auth_log_value(resp.text)}")

resp.raise_for_status()
response_data = resp.json()
debug_print(f"[VIDEO INDEXER AUTH] ARM API response keys: {list(response_data.keys())}")

ai = response_data.get("accessToken")
if not ai:
debug_print(f"[VIDEO INDEXER AUTH] ERROR: No accessToken in response: {response_data}")
debug_print(f"[VIDEO INDEXER AUTH] ERROR: No accessToken in response; response keys: {list(response_data.keys())}")
raise ValueError("No accessToken found in ARM API response")

debug_print(f"[VIDEO INDEXER AUTH] Account token acquired successfully (length: {len(ai)})")
debug_print(f"[VIDEO] Account token acquired (len={len(ai)})", flush=True)
return ai
except requests.exceptions.RequestException as e:
debug_print(f"[VIDEO INDEXER AUTH] ERROR in ARM API request: {str(e)}")
sanitized_error = _sanitize_video_indexer_auth_log_value(e)
debug_print(f"[VIDEO INDEXER AUTH] ERROR in ARM API request: {sanitized_error}")
if hasattr(e, 'response') and e.response is not None:
debug_print(f"[VIDEO INDEXER AUTH] Error response status: {e.response.status_code}")
debug_print(f"[VIDEO INDEXER AUTH] Error response text: {e.response.text}")
debug_print(f"[VIDEO INDEXER AUTH] Error response text: {_sanitize_video_indexer_auth_log_value(e.response.text)}")
raise
except Exception as e:
debug_print(f"[VIDEO INDEXER AUTH] Unexpected error: {str(e)}")
debug_print(f"[VIDEO INDEXER AUTH] Unexpected error: {_sanitize_video_indexer_auth_log_value(e)}")
raise


Expand Down
Loading
Loading