Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
matrix:
python-version: [3.12]
python-version: [3.8, 3.9]

steps:
- name: Install ldap dependencies
Expand Down
8 changes: 7 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ disable =
duplicate-code,
no-member,
parse-error,
bad-continuation,
too-few-public-methods,
global-statement,
cyclic-import,
Expand All @@ -17,11 +18,14 @@ disable =

[REPORTS]
output-format = text
files-output = no
reports = no

[FORMAT]
max-line-length = 120
max-statement-lines = 75
single-line-if-stmt = no
no-space-check = trailing-comma,dict-separator
max-module-lines = 1000
indent-string = ' '

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

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


[DESIGN]
Expand All @@ -84,4 +90,4 @@ min-public-methods = 2
max-public-methods = 20

[EXCEPTIONS]
overgeneral-exceptions = builtins.Exception
overgeneral-exceptions = Exception
24 changes: 10 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM docker.io/python:3.12-bookworm
MAINTAINER Computer Science House <webmaster@csh.rit.edu>
FROM docker.io/python:3.8-buster
MAINTAINER Devin Matte <matted@csh.rit.edu>

RUN mkdir /opt/conditional

Expand All @@ -8,23 +8,19 @@ ADD requirements.txt /opt/conditional
WORKDIR /opt/conditional

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

ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION v10.24.1
RUN mkdir -p $NVM_DIR

RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm install $NODE_VERSION"

ADD . /opt/conditional

RUN /bin/bash -c "source $NVM_DIR/nvm.sh && nvm use --delete-prefix $NODE_VERSION && npm install && npm run production"

RUN rm -rf node_modules && \
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \
apt-get -yq update && \
apt-get -yq install nodejs && \
npm install && \
npm run production && \
rm -rf node_modules && \
apt-get -yq remove nodejs npm && \
apt-get -yq clean all

RUN ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
Expand Down
30 changes: 7 additions & 23 deletions conditional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

import structlog
from csh_ldap import CSHLDAP
from flask import Flask, redirect, render_template, request, g
from flask import Flask, redirect, render_template, g
from flask_migrate import Migrate
from flask_gzip import Gzip
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
from flask_pyoidc.provider_configuration import ProviderConfiguration, ClientMetadata
from flask_sqlalchemy import SQLAlchemy

import sentry_sdk
Expand Down Expand Up @@ -40,10 +39,8 @@
app.config['LDAP_BIND_PW'],
ro=app.config['LDAP_RO'])

client_metadata = ClientMetadata(app.config["OIDC_CLIENT_CONFIG"])
provider_config = ProviderConfiguration(issuer=app.config["OIDC_ISSUER"], client_registration_info=client_metadata)

auth = OIDCAuthentication({'default': provider_config}, app)
auth = OIDCAuthentication(app, issuer=app.config["OIDC_ISSUER"],
client_registration_info=app.config["OIDC_CLIENT_CONFIG"])

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

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


# Configure Logging
def request_processor(logger, log_method, event_dict): # pylint: disable=unused-argument, redefined-outer-name
if 'request' in event_dict:
Expand Down Expand Up @@ -101,7 +99,6 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
# pylint: disable=wrong-import-order
from conditional.util import context_processors
from conditional.util.auth import get_user
from conditional.util.member import gatekeep_status
from .blueprints.dashboard import dashboard_bp # pylint: disable=ungrouped-imports
from .blueprints.attendance import attendance_bp
from .blueprints.major_project_submission import major_project_bp
Expand Down Expand Up @@ -140,7 +137,7 @@ def static_proxy(path):


@app.route('/')
@auth.oidc_auth("default")
@auth.oidc_auth
def default_route():
return redirect('/dashboard')

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


@app.route("/gatekeep/<username>")
def gatekeep(username):
token = request.headers.get("X-VOTE-TOKEN", "")
if token != app.config["VOTE_TOKEN"]:
return "Users cannot access this page", 403
try:
gatekeep_data = gatekeep_status(username)
except KeyError:
return "", 404

return gatekeep_data, 200


@app.errorhandler(404)
@app.errorhandler(500)
@auth.oidc_auth("default")
@auth.oidc_auth
@get_user
def route_errors(error, user_dict=None):
data = {}
data = dict()

# Handle the case where the header isn't present
if user_dict['username'] is not None:
Expand Down
Loading
Loading