From 689f4a92ac6d44c2c4a2bf978014a7248b536874 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 15:37:49 -0400 Subject: [PATCH 01/21] optimize imports --- .idea/.gitignore | 8 + .idea/audiophiler.iml | 25 +++ .idea/inspectionProfiles/Project_Default.xml | 12 ++ .../inspectionProfiles/profiles_settings.xml | 6 + .idea/misc.xml | 7 + .idea/modules.xml | 8 + .idea/vcs.xml | 7 + Containerfile | 13 ++ audiophiler/__init__.py | 12 +- audiophiler/ldap.py | 20 --- requirements.in | 10 ++ requirements.txt | 156 ++++++++++++++++-- setup.cfg | 6 +- 13 files changed, 243 insertions(+), 47 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/audiophiler.iml create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Containerfile delete mode 100644 audiophiler/ldap.py create mode 100644 requirements.in diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/audiophiler.iml b/.idea/audiophiler.iml new file mode 100644 index 0000000..adde81f --- /dev/null +++ b/.idea/audiophiler.iml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..06bb031 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..24b0cee --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..32fadd0 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..8306744 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..4af62cb --- /dev/null +++ b/Containerfile @@ -0,0 +1,13 @@ +FROM docker.io/python:3.9 + +WORKDIR /app +COPY . ./ + +#RUN apt update +#RUN apt install libsasl2-dev + +RUN pip install -r requirements.txt +#RUN python setup.py install + +ENV FLASK_APP=audiophiler +CMD ["flask", "run"] diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index 8c64c4b..9dc66ab 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -5,7 +5,6 @@ import os import random import subprocess -import json import requests import flask_migrate from flask import Flask, render_template, request, jsonify, redirect @@ -13,7 +12,6 @@ from flask_pyoidc.flask_pyoidc import OIDCAuthentication from flask_sqlalchemy import SQLAlchemy from werkzeug.utils import secure_filename -from csh_ldap import CSHLDAP from audiophiler.s3 import * @@ -50,12 +48,6 @@ from audiophiler.models import File, Harold, Auth, Tour from audiophiler.util import * -# Create CSHLDAP connection -ldap = CSHLDAP(app.config["LDAP_BIND_DN"], - app.config["LDAP_BIND_PW"]) - -# Import ldap functions after creating ldap conn -from audiophiler.ldap import ldap_is_eboard, ldap_is_rtp # Disable SSL certificate verification warning requests.packages.urllib3.disable_warnings() @@ -80,8 +72,8 @@ def home(auth_dict=None): db_files = db_files.paginate(page=page, per_page=page_size).items harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) + is_rtp = 'active_rtp' in auth_dict["groups"] + is_eboard = 'eboard' in auth_dict["groups" ] return render_template("main.html", db_files=db_files, get_date_modified=get_date_modified, s3_bucket=s3_bucket, auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, diff --git a/audiophiler/ldap.py b/audiophiler/ldap.py deleted file mode 100644 index 78a8ed6..0000000 --- a/audiophiler/ldap.py +++ /dev/null @@ -1,20 +0,0 @@ -# File: ldap.py -# Audiophiler CSHLDAP calls - -from audiophiler import ldap - -def ldap_is_eboard(uid): - #find member object using uid - member = ldap.get_member(uid, uid=True) - #get groups that the member is part of - group_list = member.get("memberOf") - #compare every group the member is in to see - #if it matches eboard - for group_dn in group_list: - if group_dn.split(",")[0][3:] == "eboard": - return True - return False - -def ldap_is_rtp(uid): - rtp_group = ldap.get_group("rtp") - return rtp_group.check_member(ldap.get_member(uid, uid=True)) diff --git a/requirements.in b/requirements.in new file mode 100644 index 0000000..2112f3b --- /dev/null +++ b/requirements.in @@ -0,0 +1,10 @@ +flask +werkzeug +flask-pyoidc +boto +gunicorn +flask_sqlalchemy +flask_migrate +psycopg2 +requests +pylint \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 3493df4..68ae8ad 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,13 +1,143 @@ -pbr -flask -werkzeug -flask-pyoidc -boto -gunicorn -flask_sqlalchemy -flask_migrate -psycopg2 -requests -csh_ldap -pylint -boto \ No newline at end of file +# This file is autogenerated by pip-compile with Python 3.9 +# by the following command: +# +# pip-compile +# +alembic==1.16.5 + # via flask-migrate +annotated-types==0.7.0 + # via pydantic +astroid==3.3.11 + # via pylint +blinker==1.9.0 + # via flask +boto==2.49.0 + # via -r requirements.in +certifi==2025.10.5 + # via requests +cffi==2.0.0 + # via cryptography +charset-normalizer==3.4.3 + # via requests +click==8.1.8 + # via flask +cryptography==46.0.2 + # via oic +defusedxml==0.7.1 + # via oic +dill==0.4.0 + # via pylint +flask==3.1.2 + # via + # -r requirements.in + # flask-migrate + # flask-pyoidc + # flask-sqlalchemy +flask-migrate==4.1.0 + # via -r requirements.in +flask-pyoidc==3.14.3 + # via -r requirements.in +flask-sqlalchemy==3.1.1 + # via + # -r requirements.in + # flask-migrate +future==1.0.0 + # via pyjwkest +greenlet==3.2.4 + # via sqlalchemy +gunicorn==23.0.0 + # via -r requirements.in +idna==3.11 + # via requests +importlib-metadata==8.7.0 + # via + # flask + # isort +importlib-resources==6.5.2 + # via flask-pyoidc +isort==6.1.0 + # via pylint +itsdangerous==2.2.0 + # via flask +jinja2==3.1.6 + # via flask +mako==1.3.10 + # via + # alembic + # oic +markupsafe==3.0.3 + # via + # flask + # jinja2 + # mako + # werkzeug +mccabe==0.7.0 + # via pylint +oic==1.6.1 + # via flask-pyoidc +packaging==25.0 + # via gunicorn +platformdirs==4.4.0 + # via pylint +psycopg2==2.9.11 + # via -r requirements.in +pycparser==2.23 + # via cffi +pycryptodomex==3.23.0 + # via + # oic + # pyjwkest +pydantic==2.12.0 + # via pydantic-settings +pydantic-core==2.41.1 + # via pydantic +pydantic-settings==2.11.0 + # via oic +pyjwkest==1.4.4 + # via oic +pylint==3.3.9 + # via -r requirements.in +python-dotenv==1.1.1 + # via pydantic-settings +requests==2.32.5 + # via + # -r requirements.in + # flask-pyoidc + # oic + # pyjwkest +six==1.17.0 + # via pyjwkest +sqlalchemy==2.0.44 + # via + # alembic + # flask-sqlalchemy +tomli==2.3.0 + # via + # alembic + # pylint +tomlkit==0.13.3 + # via pylint +typing-extensions==4.15.0 + # via + # alembic + # astroid + # cryptography + # pydantic + # pydantic-core + # pylint + # sqlalchemy + # typing-inspection +typing-inspection==0.4.2 + # via + # pydantic + # pydantic-settings +urllib3==2.5.0 + # via requests +werkzeug==3.1.3 + # via + # -r requirements.in + # flask +zipp==3.23.0 + # via + # importlib-metadata + # importlib-resources diff --git a/setup.cfg b/setup.cfg index f380638..5472d1b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,4 @@ [metadata] name = audiophiler -author = Stephen Greene -author-email = sgreene570@gmail.com -url = "https://github.com/sgreene570/audiophiler" -description-file = README.md +url = "https://github.com/ComputerScienceHouse/audiophiler" +description_file = README.md From b40102361244065b1f305c5924e83524746d600e Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 15:39:07 -0400 Subject: [PATCH 02/21] gitignore --- .gitignore | 3 ++- .idea/.gitignore | 8 ------ .idea/audiophiler.iml | 25 ------------------- .idea/inspectionProfiles/Project_Default.xml | 12 --------- .../inspectionProfiles/profiles_settings.xml | 6 ----- .idea/misc.xml | 7 ------ .idea/modules.xml | 8 ------ .idea/vcs.xml | 7 ------ 8 files changed, 2 insertions(+), 74 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/audiophiler.iml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 9e5f6aa..158459b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.vscode/ +.idea/ __pycache__ *env config.py @@ -7,4 +9,3 @@ AUTHORS ChangeLog creds .eggs -.vscode diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/audiophiler.iml b/.idea/audiophiler.iml deleted file mode 100644 index adde81f..0000000 --- a/.idea/audiophiler.iml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 06bb031..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 105ce2d..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 24b0cee..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 32fadd0..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 8306744..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file From 2fb5b98909d98f4bee90f2fe3edf5dc7bf9069c7 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 15:39:49 -0400 Subject: [PATCH 03/21] gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 158459b..af72c01 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .vscode/ .idea/ +.venv/ __pycache__ *env config.py From ec1653ddbd8f9e178f81c60eaa4b52085eafa731 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 15:54:00 -0400 Subject: [PATCH 04/21] git revision in container now --- Containerfile | 4 +--- audiophiler/__init__.py | 3 --- config.env.py | 3 +++ 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Containerfile b/Containerfile index 4af62cb..45b738b 100644 --- a/Containerfile +++ b/Containerfile @@ -3,11 +3,9 @@ FROM docker.io/python:3.9 WORKDIR /app COPY . ./ -#RUN apt update -#RUN apt install libsasl2-dev +RUN export GIT_REVISION=$(git rev-parse --short HEAD); echo "GIT COMMIT $GIT_REVISION" RUN pip install -r requirements.txt -#RUN python setup.py install ENV FLASK_APP=audiophiler CMD ["flask", "run"] diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index 9dc66ab..d1f2601 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -24,9 +24,6 @@ else: app.config.from_pyfile(os.path.join(os.getcwd(), "config.env.py")) -git_cmd = ['git', 'rev-parse', '--short', 'HEAD'] -app.config["GIT_REVISION"] = subprocess.check_output(git_cmd).decode('utf-8').rstrip() - _config = ProviderConfiguration( app.config['OIDC_ISSUER'], client_metadata = ClientMetadata( diff --git a/config.env.py b/config.env.py index 1fb9a81..7796dff 100644 --- a/config.env.py +++ b/config.env.py @@ -17,6 +17,9 @@ "post_logout_redirect_uris": [os.getenv("OIDC_LOGOUT_REDIRECT_URI", default="https://audiophiler.csh.rit.edu/logout")] } +# Git Hash +GIT_REVISION = os.getenv("GIT_REVISION", default="UNKNOWN").rstrip() + # Openshift secret SECRET_KEY = os.getenv("SECRET_KEY", default=''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(64))) From 3642a66bf59173501d3cd4e1323febd35a39d15c Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 16:02:27 -0400 Subject: [PATCH 05/21] use gunicorn instead of flask for pdod --- Containerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Containerfile b/Containerfile index 45b738b..d12efc4 100644 --- a/Containerfile +++ b/Containerfile @@ -2,10 +2,7 @@ FROM docker.io/python:3.9 WORKDIR /app COPY . ./ - RUN export GIT_REVISION=$(git rev-parse --short HEAD); echo "GIT COMMIT $GIT_REVISION" - RUN pip install -r requirements.txt -ENV FLASK_APP=audiophiler -CMD ["flask", "run"] +CMD ["gunicorn", "audiophiler:app"] From f6bdb96404cccc34df6cb88d737213ddb83c56d5 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 16:05:16 -0400 Subject: [PATCH 06/21] listen on all interfaces --- Containerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containerfile b/Containerfile index d12efc4..e54f39a 100644 --- a/Containerfile +++ b/Containerfile @@ -5,4 +5,4 @@ COPY . ./ RUN export GIT_REVISION=$(git rev-parse --short HEAD); echo "GIT COMMIT $GIT_REVISION" RUN pip install -r requirements.txt -CMD ["gunicorn", "audiophiler:app"] +CMD ["gunicorn", "-b", "0.0.0.0", "audiophiler:app"] From 26e0c2fa4e95686f6c1d635a3419f86adb079e5c Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 22:52:40 -0400 Subject: [PATCH 07/21] https --- config.env.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/config.env.py b/config.env.py index 7796dff..80a191c 100644 --- a/config.env.py +++ b/config.env.py @@ -16,6 +16,7 @@ "client_secret": os.getenv("OIDC_CLIENT_SECRET", default=None), "post_logout_redirect_uris": [os.getenv("OIDC_LOGOUT_REDIRECT_URI", default="https://audiophiler.csh.rit.edu/logout")] } +OIDC_REDIRECT_URI = os.getenv("OIDC_REDIRECT_URI", default="https://"+SERVER_NAME) # Git Hash GIT_REVISION = os.getenv("GIT_REVISION", default="UNKNOWN").rstrip() @@ -26,10 +27,6 @@ # Database credentials SQLALCHEMY_DATABASE_URI = os.getenv("SQLALCHEMY_DATABASE_URI", default=None) -# CSH_LDAP credentials -LDAP_BIND_DN = os.getenv("LDAP_BIND_DN", default="cn=audiophiler,ou=Apps,dc=csh,dc=rit,dc=edu") -LDAP_BIND_PW = os.getenv("LDAP_BIND_PW", default=None) - PLUG_SUPPORT = os.environ.get('PLUG_ENABLED', False) PAGE_SIZE = os.environ.get('PAGE_SIZE', 20) From bdc4cd4ff17dae2a27de0459d2d78de991aedd27 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 22:55:40 -0400 Subject: [PATCH 08/21] more https --- config.env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.env.py b/config.env.py index 80a191c..0d6a93c 100644 --- a/config.env.py +++ b/config.env.py @@ -16,7 +16,7 @@ "client_secret": os.getenv("OIDC_CLIENT_SECRET", default=None), "post_logout_redirect_uris": [os.getenv("OIDC_LOGOUT_REDIRECT_URI", default="https://audiophiler.csh.rit.edu/logout")] } -OIDC_REDIRECT_URI = os.getenv("OIDC_REDIRECT_URI", default="https://"+SERVER_NAME) +OIDC_REDIRECT_URI = os.getenv("OIDC_REDIRECT_URI", default="https://"+SERVER_NAME+"/redirect_uri") # Git Hash GIT_REVISION = os.getenv("GIT_REVISION", default="UNKNOWN").rstrip() From f6473ffc4ffa5868dca03a42338add7cf2b02309 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 22:59:03 -0400 Subject: [PATCH 09/21] debug --- audiophiler/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index d1f2601..d722854 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -69,6 +69,7 @@ def home(auth_dict=None): db_files = db_files.paginate(page=page, per_page=page_size).items harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") + print(auth_dict) is_rtp = 'active_rtp' in auth_dict["groups"] is_eboard = 'eboard' in auth_dict["groups" ] return render_template("main.html", db_files=db_files, From dc9adcae0d53ca39be11d21518326847d4f65a62 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:03:09 -0400 Subject: [PATCH 10/21] hell --- audiophiler/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index d722854..c4d3839 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -60,6 +60,8 @@ def home(auth_dict=None): name = args.get("name", default=None, type=str) author = args.get("author", default=None, type=str) page_size = args.get("size",default=default_size, type=int) + print('balls') + print(auth_dict) # Retrieve list of files for templating db_files = File.query if name: @@ -69,7 +71,6 @@ def home(auth_dict=None): db_files = db_files.paginate(page=page, per_page=page_size).items harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") - print(auth_dict) is_rtp = 'active_rtp' in auth_dict["groups"] is_eboard = 'eboard' in auth_dict["groups" ] return render_template("main.html", db_files=db_files, From 48903197f363165a6855bf525361a5a53880735b Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:09:46 -0400 Subject: [PATCH 11/21] oh i see the rainbow --- audiophiler/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/audiophiler/util.py b/audiophiler/util.py index f71c1c5..d2c9397 100644 --- a/audiophiler/util.py +++ b/audiophiler/util.py @@ -12,9 +12,12 @@ def audiophiler_auth(func): def wrapped_function(*args, **kwargs): uuid = str(session["userinfo"].get("sub", "")) uid = str(session["userinfo"].get("preferred_username", "")) + groups = str(session["groups"].get("groups", [])) + print(session) auth_dict = { "uuid": uuid, - "uid": uid + "uid": uid, + "groups": groups, } kwargs["auth_dict"] = auth_dict return func(*args, **kwargs) From 6718600b9a8b7a269f293c28713b0008084e3f7e Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:12:06 -0400 Subject: [PATCH 12/21] debug2 --- audiophiler/util.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audiophiler/util.py b/audiophiler/util.py index d2c9397..5db1dd6 100644 --- a/audiophiler/util.py +++ b/audiophiler/util.py @@ -10,10 +10,10 @@ def audiophiler_auth(func): @wraps(func) def wrapped_function(*args, **kwargs): + print(session) uuid = str(session["userinfo"].get("sub", "")) uid = str(session["userinfo"].get("preferred_username", "")) groups = str(session["groups"].get("groups", [])) - print(session) auth_dict = { "uuid": uuid, "uid": uid, From d6e951544d08949005ff8c49e0d473e540c9b206 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:14:25 -0400 Subject: [PATCH 13/21] broke things --- audiophiler/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/audiophiler/util.py b/audiophiler/util.py index 5db1dd6..b799e17 100644 --- a/audiophiler/util.py +++ b/audiophiler/util.py @@ -10,10 +10,10 @@ def audiophiler_auth(func): @wraps(func) def wrapped_function(*args, **kwargs): - print(session) + print(session["userinfo"]) uuid = str(session["userinfo"].get("sub", "")) uid = str(session["userinfo"].get("preferred_username", "")) - groups = str(session["groups"].get("groups", [])) + groups = str(session["userinfo"].get("groups", [])) auth_dict = { "uuid": uuid, "uid": uid, From 5e7fc660912211c455c7a5a741a18eb3d8184e82 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:17:08 -0400 Subject: [PATCH 14/21] debug removed, just prod --- audiophiler/__init__.py | 2 -- audiophiler/util.py | 1 - 2 files changed, 3 deletions(-) diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index c4d3839..d1f2601 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -60,8 +60,6 @@ def home(auth_dict=None): name = args.get("name", default=None, type=str) author = args.get("author", default=None, type=str) page_size = args.get("size",default=default_size, type=int) - print('balls') - print(auth_dict) # Retrieve list of files for templating db_files = File.query if name: diff --git a/audiophiler/util.py b/audiophiler/util.py index b799e17..5eb8462 100644 --- a/audiophiler/util.py +++ b/audiophiler/util.py @@ -10,7 +10,6 @@ def audiophiler_auth(func): @wraps(func) def wrapped_function(*args, **kwargs): - print(session["userinfo"]) uuid = str(session["userinfo"].get("sub", "")) uid = str(session["userinfo"].get("preferred_username", "")) groups = str(session["userinfo"].get("groups", [])) From ac30611f12f752cc6e50df03592734620cc3199c Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:25:43 -0400 Subject: [PATCH 15/21] changed on all pages --- audiophiler/__init__.py | 37 ++++++++++--------------------------- audiophiler/util.py | 2 ++ 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index d1f2601..c2c935d 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -69,12 +69,10 @@ def home(auth_dict=None): db_files = db_files.paginate(page=page, per_page=page_size).items harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") - is_rtp = 'active_rtp' in auth_dict["groups"] - is_eboard = 'eboard' in auth_dict["groups" ] return render_template("main.html", db_files=db_files, get_date_modified=get_date_modified, s3_bucket=s3_bucket, auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, - is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False, route="", page=page) + is_rtp=auth_dict["is_rtp"], is_eboard=auth_dict["is_eboard"], is_tour_page=False, route="", page=page) @app.route("/mine") @auth.oidc_auth('default') @@ -89,15 +87,13 @@ def mine(auth_dict=None): if name: db_files = db_files.filter(File.name.like(f"%{name}%")) db_files = db_files.paginate(page=page, per_page=page_size).items - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) # Retrieve list of files for templating harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") return render_template("main.html", db_files=db_files, get_file_s3=get_file_s3, get_date_modified=get_date_modified, s3_bucket=s3_bucket, auth_dict=auth_dict, harolds=harolds, - tour_harolds=tour_harolds, is_rtp=is_rtp, is_eboard=is_eboard, + tour_harolds=tour_harolds, is_rtp=auth_dict["is_rtp"], is_eboard=auth_dict["is_eboard"], is_tour_page=False, route="mine", page=page) @app.route("/selected") @@ -109,9 +105,6 @@ def selected(auth_dict=None): name = args.get("name", default=None, type=str) author = args.get("author", default=None, type=str) page_size = args.get("size",default=default_size, type=int) - # Retrieve list of files for templating - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) #Retrieve list of files for templating harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") @@ -124,7 +117,7 @@ def selected(auth_dict=None): return render_template("main.html", db_files=db_files, get_date_modified=get_date_modified, s3_bucket=s3_bucket, auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, - is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=False, + is_rtp=auth_dict["is_rtp"], is_eboard=auth_dict["is_eboard"], is_tour_page=False, route="selected", page=page) @app.route("/tour_page") @@ -136,8 +129,6 @@ def admin(auth_dict=None): name = args.get("name", default=None, type=str) author = args.get("author", default=None, type=str) page_size = args.get("size",default=default_size, type=int) - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) if is_eboard or is_rtp: harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") @@ -150,7 +141,7 @@ def admin(auth_dict=None): return render_template("main.html", db_files=db_files, get_date_modified=get_date_modified, s3_bucket=s3_bucket, auth_dict=auth_dict, harolds=harolds, tour_harolds=tour_harolds, - is_rtp=is_rtp, is_eboard=is_eboard, is_tour_page=True, + is_rtp=auth_dict["is_rtp"], is_eboard=auth_dict["is_eboard"], is_tour_page=True, is_tour_mode=get_tour_lock_status(), route="tour_page", page=page) @@ -160,16 +151,14 @@ def admin(auth_dict=None): @auth.oidc_auth('default') @audiophiler_auth def upload_page(auth_dict=None): - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) - return render_template("upload.html", is_rtp=is_rtp, is_eboard=is_eboard, auth_dict=auth_dict) + return render_template("upload.html", is_rtp=auth_dict["is_rtp"], is_eboard=auth_dict["is_eboard"], auth_dict=auth_dict) @app.route("/upload", methods=["POST"]) @auth.oidc_auth('default') @audiophiler_auth def upload(auth_dict=None): uploaded_files = [t[1] for t in request.files.items()] - upload_status = {} + upload_status = dict() upload_status["error"] = [] upload_status["success"] = [] @@ -222,7 +211,7 @@ def delete_file(file_hash, auth_dict=None): return "File Not Found", 404 if not auth_dict["uid"] == file_model.author: - if not (ldap_is_eboard(auth_dict["uid"]) or ldap_is_rtp(auth_dict["uid"])): + if not auth_dict["is_rtp"] or auth_dict["is_eboard"]: return "Permission Denied", 403 # Delete file model @@ -248,10 +237,8 @@ def get_s3_url(file_hash, auth_dict=None): @audiophiler_auth def set_harold(file_hash, auth_dict=None): is_tour = request.json["tour"] - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) if is_tour == "true": - if (is_rtp or is_eboard): + if auth_dict["is_rtp"] or auth_dict["is_eboard"]: uid = "root" else: return "Not Authorized", 403 @@ -269,10 +256,8 @@ def set_harold(file_hash, auth_dict=None): @audiophiler_auth def remove_harold(file_hash, auth_dict=None): is_tour = request.json["tour"] - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) if is_tour == "true": - if is_rtp or is_eboard: + if auth_dict["is_rtp"] or auth_dict["is_eboard"]: uid = "root" else: return "Not Authorized", 403 @@ -317,9 +302,7 @@ def get_harold(uid, auth_dict=None): @auth.oidc_auth('default') @audiophiler_auth def toggle_tour_mode(auth_dict=None): - is_rtp = ldap_is_rtp(auth_dict["uid"]) - is_eboard = ldap_is_eboard(auth_dict["uid"]) - if is_rtp or is_eboard: + if auth_dict["is_rtp"] or auth_dict["is_eboard"]: admin_query = Tour.query.first() if request.json["state"] == "t": admin_query.tour_lock = True diff --git a/audiophiler/util.py b/audiophiler/util.py index 5eb8462..a3c80d5 100644 --- a/audiophiler/util.py +++ b/audiophiler/util.py @@ -17,6 +17,8 @@ def wrapped_function(*args, **kwargs): "uuid": uuid, "uid": uid, "groups": groups, + "is_rtp": 'active_rtp' in groups, + "is_eboard": 'eboard' in groups, } kwargs["auth_dict"] = auth_dict return func(*args, **kwargs) From 3a4d8e6e31b94ab54672612f0f00dbb26c1c1978 Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Mon, 13 Oct 2025 23:40:41 -0400 Subject: [PATCH 16/21] git revision does other things --- Containerfile | 2 +- audiophiler/__init__.py | 2 +- config.env.py | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Containerfile b/Containerfile index e54f39a..6525fb3 100644 --- a/Containerfile +++ b/Containerfile @@ -2,7 +2,7 @@ FROM docker.io/python:3.9 WORKDIR /app COPY . ./ -RUN export GIT_REVISION=$(git rev-parse --short HEAD); echo "GIT COMMIT $GIT_REVISION" +RUN git rev-parse --short HEAD > commit.txt RUN pip install -r requirements.txt CMD ["gunicorn", "-b", "0.0.0.0", "audiophiler:app"] diff --git a/audiophiler/__init__.py b/audiophiler/__init__.py index c2c935d..e05268a 100644 --- a/audiophiler/__init__.py +++ b/audiophiler/__init__.py @@ -129,7 +129,7 @@ def admin(auth_dict=None): name = args.get("name", default=None, type=str) author = args.get("author", default=None, type=str) page_size = args.get("size",default=default_size, type=int) - if is_eboard or is_rtp: + if auth_dict["is_rtp"] or auth_dict["is_eboard"]: harolds = get_harold_list(auth_dict["uid"]) tour_harolds = get_harold_list("root") db_files = File.query.filter(File.file_hash.in_(tour_harolds)) diff --git a/config.env.py b/config.env.py index 0d6a93c..2eb401f 100644 --- a/config.env.py +++ b/config.env.py @@ -19,7 +19,8 @@ OIDC_REDIRECT_URI = os.getenv("OIDC_REDIRECT_URI", default="https://"+SERVER_NAME+"/redirect_uri") # Git Hash -GIT_REVISION = os.getenv("GIT_REVISION", default="UNKNOWN").rstrip() +with open('commit.txt') as f: s = f.read() +GIT_REVISION = s # Openshift secret SECRET_KEY = os.getenv("SECRET_KEY", default=''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(64))) From 65050f6e6c41d84282e0cd0eaa19bd278cc1067d Mon Sep 17 00:00:00 2001 From: Tyler Allen Date: Tue, 14 Oct 2025 00:25:20 -0400 Subject: [PATCH 17/21] workflow upgrade --- .github/workflows/pylint.yml | 6 ++---- audiophiler/templates/base.html | 2 +- config.env.py | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index cfc64cb..0f3d1f8 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -15,11 +15,9 @@ jobs: strategy: matrix: - python-version: [3.6] + python-version: [3.9] steps: - - name: Install ldap dependencies - run: sudo apt-get update && sudo apt-get install libldap2-dev libsasl2-dev - uses: actions/checkout@v2 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 @@ -27,7 +25,7 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - python -m pip install --upgrade pip + #python -m pip install --upgrade pip pip install -r requirements.txt - name: Lint with pylint run: | diff --git a/audiophiler/templates/base.html b/audiophiler/templates/base.html index a30dde7..149cad8 100644 --- a/audiophiler/templates/base.html +++ b/audiophiler/templates/base.html @@ -105,7 +105,7 @@ {% endblock %}