Skip to content

Commit 7ae94c9

Browse files
committed
Merging with OIDC PR
1 parent 549caa8 commit 7ae94c9

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

conditional/__init__.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,18 @@
55
import subprocess
66
from datetime import datetime
77

8-
import structlog
98
from csh_ldap import CSHLDAP
10-
from flask import Flask, redirect, request, render_template, g
9+
from flask import Flask, redirect, render_template, g
1110
from flask_migrate import Migrate
1211
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
1312
from flask_sqlalchemy import SQLAlchemy
1413
from raven.contrib.flask import Sentry
15-
from raven.exceptions import InvalidGitRepository
1614
import structlog
1715

1816
from conditional import config
1917

2018
app = Flask(__name__)
2119

22-
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
23-
2420
app.config.from_object(config)
2521
if os.path.exists(os.path.join(os.getcwd(), "config.py")):
2622
app.config.from_pyfile(os.path.join(os.getcwd(), "config.py"))
@@ -45,12 +41,14 @@
4541

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

44+
4845
def start_of_year():
4946
start = datetime(datetime.today().year, 6, 1)
5047
if datetime.today() < start:
5148
start = datetime(datetime.today().year - 1, 6, 1)
5249
return start
5350

51+
5452
# pylint: disable=C0413
5553
from .models.models import UserLog
5654

@@ -84,6 +82,7 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
8482
del event_dict['request']
8583
return event_dict
8684

85+
8786
structlog.configure(processors=[
8887
request_processor,
8988
database_processor,
@@ -132,9 +131,17 @@ def static_proxy(path):
132131

133132

134133
@app.route('/')
134+
@auth.oidc_auth
135135
def default_route():
136136
return redirect('/dashboard')
137137

138+
139+
@app.route("/logout")
140+
@auth.oidc_logout
141+
def logout():
142+
return redirect("/", 302)
143+
144+
138145
@app.errorhandler(404)
139146
@app.errorhandler(500)
140147
@auth.oidc_auth

conditional/config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,13 @@
2323
'release': __version__,
2424
}
2525

26+
# OIDC Config
27+
OIDC_ISSUER = env.get("CONDITIONAL_OIDC_ISSUER", "https://sso.csh.rit.edu/auth/realms/csh")
28+
OIDC_CLIENT_CONFIG = {
29+
'client_id': env.get("CONDITIONAL_OIDC_CLIENT_ID", "conditional"),
30+
'client_secret': env.get("CONDITIONAL_OIDC_CLIENT_SECRET", ""),
31+
'post_logout_redirect_uris': [env.get("CONDITIONAL_OIDC_CLIENT_LOGOUT", "http://0.0.0.0:6969/logout")]
32+
}
33+
2634
# General config
2735
DUES_PER_SEMESTER = env.get("CONDITIONAL_DUES_PER_SEMESTER", 80)

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ Flask-Migrate==2.1.1
88
Flask-pyoidc==1.2.0
99
Flask-SQLAlchemy==2.3.2
1010
gunicorn==19.7.1
11-
isort==4.2.15
1211
isort==4.3.4
1312
itsdangerous==0.24
1413
Jinja2==2.10

0 commit comments

Comments
 (0)