Skip to content

Commit 549caa8

Browse files
committed
Fixing Merge Conflicts!
2 parents 72e37d9 + 54c27fb commit 549caa8

20 files changed

+453
-504
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: python
22
python:
3-
- "3.3"
3+
- "3.6"
44

55
install:
66
- "pip install -r requirements.txt"

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,24 @@ Then, install the pipeline and frontend dependencies:
3131
npm install
3232
```
3333

34+
### Config
35+
3436
You must create `config.py` in the top-level directory with the appropriate credentials for the application to run. See `config.sample.py` for an example.
3537

38+
#### Add OIDC Config
39+
Reach out to an RTP to get OIDC credentials that will allow you to develop locally behind OIDC auth
40+
```
41+
# OIDC Config
42+
OIDC_ISSUER = "https://sso.csh.rit.edu/auth/realms/csh"
43+
OIDC_CLIENT_CONFIG = {
44+
'client_id': '',
45+
'client_secret': '',
46+
'post_logout_redirect_uris': ['http://0.0.0.0:6969/logout']
47+
}
48+
```
49+
50+
### Run
51+
3652
Once you have all of the dependencies installed, simply run:
3753

3854
```

conditional/__init__.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,36 @@
22
from ._version import __version__
33

44
import os
5+
import subprocess
56
from datetime import datetime
67

78
import structlog
89
from csh_ldap import CSHLDAP
910
from flask import Flask, redirect, request, render_template, g
1011
from flask_migrate import Migrate
12+
from flask_pyoidc.flask_pyoidc import OIDCAuthentication
1113
from flask_sqlalchemy import SQLAlchemy
1214
from raven.contrib.flask import Sentry
15+
from raven.exceptions import InvalidGitRepository
16+
import structlog
1317

1418
from conditional import config
1519

1620
app = Flask(__name__)
1721

22+
config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py")
23+
1824
app.config.from_object(config)
1925
if os.path.exists(os.path.join(os.getcwd(), "config.py")):
2026
app.config.from_pyfile(os.path.join(os.getcwd(), "config.py"))
2127

2228
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
2329

30+
app.config["GIT_REVISION"] = subprocess.check_output(['git',
31+
'rev-parse',
32+
'--short',
33+
'HEAD']).decode('utf-8').rstrip()
34+
2435
db = SQLAlchemy(app)
2536
migrate = Migrate(app, db)
2637
sentry = Sentry(app)
@@ -29,14 +40,17 @@
2940
app.config['LDAP_BIND_PW'],
3041
ro=app.config['LDAP_RO'])
3142

43+
auth = OIDCAuthentication(app, issuer=app.config["OIDC_ISSUER"],
44+
client_registration_info=app.config["OIDC_CLIENT_CONFIG"])
45+
46+
app.secret_key = app.config["SECRET_KEY"]
3247

3348
def start_of_year():
3449
start = datetime(datetime.today().year, 6, 1)
3550
if datetime.today() < start:
3651
start = datetime(datetime.today().year - 1, 6, 1)
3752
return start
3853

39-
4054
# pylint: disable=C0413
4155
from .models.models import UserLog
4256

@@ -70,7 +84,6 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
7084
del event_dict['request']
7185
return event_dict
7286

73-
7487
structlog.configure(processors=[
7588
request_processor,
7689
database_processor,
@@ -79,6 +92,8 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse
7992

8093
logger = structlog.get_logger()
8194

95+
from conditional.util.auth import get_user
96+
8297
from .blueprints.dashboard import dashboard_bp # pylint: disable=ungrouped-imports
8398
from .blueprints.attendance import attendance_bp
8499
from .blueprints.major_project_submission import major_project_bp
@@ -120,18 +135,17 @@ def static_proxy(path):
120135
def default_route():
121136
return redirect('/dashboard')
122137

123-
124138
@app.errorhandler(404)
125139
@app.errorhandler(500)
126-
def route_errors(error):
140+
@auth.oidc_auth
141+
@get_user
142+
def route_errors(error, user_dict=None):
127143
data = dict()
128-
username = request.headers.get('x-webauth-user')
129144

130145
# Handle the case where the header isn't present
131-
if username is not None:
132-
member = ldap_get_member(username)
133-
data['username'] = member.uid
134-
data['name'] = member.cn
146+
if user_dict['username'] is not None:
147+
data['username'] = user_dict['account'].uid
148+
data['name'] = user_dict['account'].cn
135149
else:
136150
data['username'] = "unknown"
137151
data['name'] = "Unknown"

0 commit comments

Comments
 (0)