Skip to content

Commit e4622cc

Browse files
authored
Merge branch 'develop' into develop
2 parents 1f43a32 + e33200a commit e4622cc

File tree

97 files changed

+5633
-15370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+5633
-15370
lines changed

.github/pull_request_template.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## What
2+
3+
_what the PR changes_
4+
5+
## Why
6+
7+
_why these changes were made_
8+
9+
## Test Plan
10+
11+
_how did you verify these changes did what you expected_
12+
13+
## Env Vars
14+
15+
_did you add, remove, or rename any environment variables_
16+
17+
## Checklist
18+
19+
- [ ] Tested all changes locally

.github/workflows/node-js.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/python-app.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515

1616
strategy:
1717
matrix:
18-
python-version: [3.8, 3.9]
18+
python-version: [3.12]
1919

2020
steps:
2121
- name: Install ldap dependencies

.github/workflows/sonarqube.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- develop
7+
8+
9+
jobs:
10+
build:
11+
name: Build and analyze
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
18+
- uses: SonarSource/sonarqube-scan-action@v6
19+
env:
20+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
21+
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}

.nvmrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.pylintrc

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ disable =
99
duplicate-code,
1010
no-member,
1111
parse-error,
12-
bad-continuation,
1312
too-few-public-methods,
1413
global-statement,
1514
cyclic-import,
@@ -18,14 +17,11 @@ disable =
1817

1918
[REPORTS]
2019
output-format = text
21-
files-output = no
2220
reports = no
2321

2422
[FORMAT]
2523
max-line-length = 120
26-
max-statement-lines = 75
2724
single-line-if-stmt = no
28-
no-space-check = trailing-comma,dict-separator
2925
max-module-lines = 1000
3026
indent-string = ' '
3127

@@ -73,8 +69,6 @@ good-names=logger,id,ID
7369
# Bad variable names which should always be refused, separated by a comma
7470
bad-names=foo,bar,baz,toto,tutu,tata
7571

76-
# List of builtins function names that should not be used, separated by a comma
77-
bad-functions=apply,input
7872

7973

8074
[DESIGN]
@@ -90,4 +84,4 @@ min-public-methods = 2
9084
max-public-methods = 20
9185

9286
[EXCEPTIONS]
93-
overgeneral-exceptions = Exception
87+
overgeneral-exceptions = builtins.Exception

Dockerfile

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
FROM docker.io/python:3.8-buster
2-
MAINTAINER Devin Matte <matted@csh.rit.edu>
1+
FROM node:25-bookworm-slim AS build-frontend
2+
3+
RUN mkdir /opt/conditional
4+
5+
WORKDIR /opt/conditional
6+
7+
RUN apt-get -yq update && \
8+
apt-get -yq install curl git
9+
10+
COPY package.json package-lock.json /opt/conditional/
11+
12+
RUN npm ci
13+
14+
COPY webpack.config.js /opt/conditional
15+
COPY frontend /opt/conditional/frontend
16+
17+
RUN npm run webpack
18+
19+
FROM docker.io/python:3.12-slim-bookworm
20+
MAINTAINER Computer Science House <webmaster@csh.rit.edu>
321

422
RUN mkdir /opt/conditional
523

@@ -8,21 +26,17 @@ ADD requirements.txt /opt/conditional
826
WORKDIR /opt/conditional
927

1028
RUN apt-get -yq update && \
11-
apt-get -yq install libsasl2-dev libldap2-dev libssl-dev gcc g++ make && \
29+
apt-get -yq install libsasl2-dev libldap2-dev libldap-common libssl-dev gcc g++ make && \
1230
pip install -r requirements.txt && \
1331
apt-get -yq clean all
1432

15-
ADD . /opt/conditional
33+
ARG PORT=8080
34+
ENV PORT=${PORT}
35+
EXPOSE ${PORT}
1636

17-
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
18-
apt-get -yq update && \
19-
apt-get -yq install nodejs && \
20-
npm install && \
21-
npm run production && \
22-
rm -rf node_modules && \
23-
apt-get -yq remove nodejs npm && \
24-
apt-get -yq clean all
37+
COPY . /opt/conditional
38+
COPY --from=build-frontend /opt/conditional/conditional/static /opt/conditional/conditional/static
2539

2640
RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
2741

28-
CMD ["ddtrace-run", "gunicorn", "conditional:app", "--bind=0.0.0.0:8080", "--access-logfile=-", "--timeout=256"]
42+
CMD ["sh", "-c", "gunicorn conditional:app --bind=0.0.0.0:${PORT} --access-logfile=- --timeout=256"]

conditional/__init__.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33

44
import structlog
55
from csh_ldap import CSHLDAP
6-
from flask import Flask, redirect, render_template, g
6+
from flask import Flask, redirect, render_template, request, g
77
from flask_migrate import Migrate
88
from flask_gzip import Gzip
99
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
10+
from flask_pyoidc.provider_configuration import ProviderConfiguration, ClientMetadata
1011
from flask_sqlalchemy import SQLAlchemy
1112

1213
import sentry_sdk
@@ -39,8 +40,10 @@
3940
app.config['LDAP_BIND_PW'],
4041
ro=app.config['LDAP_RO'])
4142

42-
auth = OIDCAuthentication(app, issuer=app.config["OIDC_ISSUER"],
43-
client_registration_info=app.config["OIDC_CLIENT_CONFIG"])
43+
provider_config = ProviderConfiguration(
44+
app.config['OIDC_ISSUER'],
45+
client_metadata=ClientMetadata(**app.config['OIDC_CLIENT_CONFIG']))
46+
auth = OIDCAuthentication({'default': provider_config}, app)
4447

4548
app.secret_key = app.config["SECRET_KEY"]
4649

@@ -55,7 +58,6 @@ def start_of_year():
5558
# pylint: disable=C0413
5659
from .models.models import UserLog
5760

58-
5961
# Configure Logging
6062
def request_processor(logger, log_method, event_dict): # pylint: disable=unused-argument, redefined-outer-name
6163
if 'request' in event_dict:
@@ -99,6 +101,7 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
99101
# pylint: disable=wrong-import-order
100102
from conditional.util import context_processors
101103
from conditional.util.auth import get_user
104+
from conditional.util.member import gatekeep_status
102105
from .blueprints.dashboard import dashboard_bp # pylint: disable=ungrouped-imports
103106
from .blueprints.attendance import attendance_bp
104107
from .blueprints.major_project_submission import major_project_bp
@@ -137,7 +140,7 @@ def static_proxy(path):
137140

138141

139142
@app.route('/')
140-
@auth.oidc_auth
143+
@auth.oidc_auth("default")
141144
def default_route():
142145
return redirect('/dashboard')
143146

@@ -156,12 +159,25 @@ def health():
156159
return {'status': 'ok'}
157160

158161

162+
@app.route("/gatekeep/<username>")
163+
def gatekeep(username):
164+
token = request.headers.get("X-VOTE-TOKEN", "")
165+
if token != app.config["VOTE_TOKEN"]:
166+
return "Users cannot access this page", 403
167+
try:
168+
gatekeep_data = gatekeep_status(username)
169+
except KeyError:
170+
return "", 404
171+
172+
return gatekeep_data, 200
173+
174+
159175
@app.errorhandler(404)
160176
@app.errorhandler(500)
161-
@auth.oidc_auth
177+
@auth.oidc_auth("default")
162178
@get_user
163179
def route_errors(error, user_dict=None):
164-
data = dict()
180+
data = {}
165181

166182
# Handle the case where the header isn't present
167183
if user_dict['username'] is not None:

0 commit comments

Comments
 (0)