|
5 | 5 | import subprocess |
6 | 6 | from datetime import datetime |
7 | 7 |
|
8 | | -import structlog |
9 | 8 | from csh_ldap import CSHLDAP |
10 | | -from flask import Flask, redirect, request, render_template, g |
| 9 | +from flask import Flask, redirect, render_template, g |
11 | 10 | from flask_migrate import Migrate |
12 | 11 | from flask_pyoidc.flask_pyoidc import OIDCAuthentication |
13 | 12 | from flask_sqlalchemy import SQLAlchemy |
14 | 13 | from raven.contrib.flask import Sentry |
15 | | -from raven.exceptions import InvalidGitRepository |
16 | 14 | import structlog |
17 | 15 |
|
18 | 16 | from conditional import config |
19 | 17 |
|
20 | 18 | app = Flask(__name__) |
21 | 19 |
|
22 | | -config = os.path.join(app.config.get('ROOT_DIR', os.getcwd()), "config.py") |
23 | | - |
24 | 20 | app.config.from_object(config) |
25 | 21 | if os.path.exists(os.path.join(os.getcwd(), "config.py")): |
26 | 22 | app.config.from_pyfile(os.path.join(os.getcwd(), "config.py")) |
|
45 | 41 |
|
46 | 42 | app.secret_key = app.config["SECRET_KEY"] |
47 | 43 |
|
| 44 | + |
48 | 45 | def start_of_year(): |
49 | 46 | start = datetime(datetime.today().year, 6, 1) |
50 | 47 | if datetime.today() < start: |
51 | 48 | start = datetime(datetime.today().year - 1, 6, 1) |
52 | 49 | return start |
53 | 50 |
|
| 51 | + |
54 | 52 | # pylint: disable=C0413 |
55 | 53 | from .models.models import UserLog |
56 | 54 |
|
@@ -84,6 +82,7 @@ def database_processor(logger, log_method, event_dict): # pylint: disable=unuse |
84 | 82 | del event_dict['request'] |
85 | 83 | return event_dict |
86 | 84 |
|
| 85 | + |
87 | 86 | structlog.configure(processors=[ |
88 | 87 | request_processor, |
89 | 88 | database_processor, |
@@ -132,9 +131,17 @@ def static_proxy(path): |
132 | 131 |
|
133 | 132 |
|
134 | 133 | @app.route('/') |
| 134 | +@auth.oidc_auth |
135 | 135 | def default_route(): |
136 | 136 | return redirect('/dashboard') |
137 | 137 |
|
| 138 | + |
| 139 | +@app.route("/logout") |
| 140 | +@auth.oidc_logout |
| 141 | +def logout(): |
| 142 | + return redirect("/", 302) |
| 143 | + |
| 144 | + |
138 | 145 | @app.errorhandler(404) |
139 | 146 | @app.errorhandler(500) |
140 | 147 | @auth.oidc_auth |
|
0 commit comments