chellow 1751991276.0.0__py3-none-any.whl → 1752157293.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of chellow might be problematic. Click here for more details.
- chellow/__init__.py +45 -18
- chellow/views.py +5 -0
- {chellow-1751991276.0.0.dist-info → chellow-1752157293.0.0.dist-info}/METADATA +2 -2
- {chellow-1751991276.0.0.dist-info → chellow-1752157293.0.0.dist-info}/RECORD +5 -5
- {chellow-1751991276.0.0.dist-info → chellow-1752157293.0.0.dist-info}/WHEEL +0 -0
chellow/__init__.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import json
|
|
1
2
|
import os
|
|
3
|
+
from base64 import b64decode
|
|
2
4
|
from datetime import datetime as Datetime
|
|
3
5
|
from importlib.metadata import version
|
|
4
6
|
from pathlib import Path
|
|
@@ -127,17 +129,45 @@ def create_app(testing=False, instance_path=None):
|
|
|
127
129
|
g.config = {}
|
|
128
130
|
ad_props = g.config.get("ad_authentication", {})
|
|
129
131
|
ad_auth_on = ad_props.get("on", False)
|
|
132
|
+
easy_auth_props = g.config.get("easy_auth", {})
|
|
133
|
+
easy_auth_on = easy_auth_props.get("on", False)
|
|
134
|
+
path = request.path
|
|
135
|
+
if path in ("/health", "/robots933456.txt"):
|
|
136
|
+
return
|
|
130
137
|
if ad_auth_on:
|
|
131
138
|
username = request.headers["X-Isrw-Proxy-Logon-User"].upper()
|
|
132
|
-
user = g.sess.
|
|
139
|
+
user = g.sess.scalars(
|
|
140
|
+
select(User).where(User.email_address == username)
|
|
141
|
+
).first()
|
|
133
142
|
if user is None:
|
|
134
143
|
try:
|
|
135
144
|
username = ad_props["default_user"]
|
|
136
|
-
user = (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
user = g.sess.scalars(
|
|
146
|
+
select(User).where(User.email_address == username)
|
|
147
|
+
).first()
|
|
148
|
+
except KeyError:
|
|
149
|
+
user = None
|
|
150
|
+
if user is not None:
|
|
151
|
+
g.user = user
|
|
152
|
+
elif easy_auth_on:
|
|
153
|
+
jwt_enc = request.headers["X-MS-CLIENT-PRINCIPAL"]
|
|
154
|
+
jwt = json.loads(b64decode(jwt_enc))
|
|
155
|
+
for claim in jwt["claims"]:
|
|
156
|
+
if claim["typ"] == (
|
|
157
|
+
"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/"
|
|
158
|
+
"emailaddress"
|
|
159
|
+
):
|
|
160
|
+
username = claim["val"]
|
|
161
|
+
user = g.sess.scalars(
|
|
162
|
+
select(User).where(User.email_address == username)
|
|
163
|
+
).first()
|
|
164
|
+
break
|
|
165
|
+
if user is None:
|
|
166
|
+
try:
|
|
167
|
+
username = easy_auth_props["default_user"]
|
|
168
|
+
user = g.sess.scalars(
|
|
169
|
+
select(User).where(User.email_address == username)
|
|
170
|
+
).first()
|
|
141
171
|
except KeyError:
|
|
142
172
|
user = None
|
|
143
173
|
if user is not None:
|
|
@@ -156,25 +186,20 @@ def create_app(testing=False, instance_path=None):
|
|
|
156
186
|
key = None
|
|
157
187
|
|
|
158
188
|
email = ips[key]
|
|
159
|
-
g.user = (
|
|
160
|
-
|
|
161
|
-
)
|
|
189
|
+
g.user = g.sess.scalars(
|
|
190
|
+
select(User).where(User.email_address == email)
|
|
191
|
+
).first()
|
|
162
192
|
except KeyError:
|
|
163
193
|
pass
|
|
164
194
|
else:
|
|
165
|
-
user = (
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
.first()
|
|
169
|
-
)
|
|
195
|
+
user = g.sess.scalars(
|
|
196
|
+
select(User).where(User.email_address == auth.username)
|
|
197
|
+
).first()
|
|
170
198
|
if user is not None and user.password_matches(auth.password):
|
|
171
199
|
g.user = user
|
|
172
200
|
|
|
173
201
|
# Got our user
|
|
174
|
-
path = request.path
|
|
175
202
|
method = request.method
|
|
176
|
-
if path in ("/health",):
|
|
177
|
-
return
|
|
178
203
|
|
|
179
204
|
if g.user is not None:
|
|
180
205
|
if "X-Isrw-Proxy-Logon-User" in request.headers:
|
|
@@ -227,7 +252,9 @@ def create_app(testing=False, instance_path=None):
|
|
|
227
252
|
g.sess.commit()
|
|
228
253
|
return
|
|
229
254
|
|
|
230
|
-
if
|
|
255
|
+
if (not easy_auth_on) and (
|
|
256
|
+
(g.user is None) or (not ad_auth_on and auth is None)
|
|
257
|
+
):
|
|
231
258
|
return Response(
|
|
232
259
|
"Could not verify your access level for that URL.\n"
|
|
233
260
|
"You have to login with proper credentials",
|
chellow/views.py
CHANGED
|
@@ -198,6 +198,11 @@ def health():
|
|
|
198
198
|
return Response("healthy\n", mimetype="text/plain")
|
|
199
199
|
|
|
200
200
|
|
|
201
|
+
@home.route("/robots933456.txt")
|
|
202
|
+
def robots():
|
|
203
|
+
return Response("healthy\n", mimetype="text/plain")
|
|
204
|
+
|
|
205
|
+
|
|
201
206
|
@home.route("/local_reports/<int:report_id>/output")
|
|
202
207
|
def local_report_output_get(report_id):
|
|
203
208
|
report = g.sess.execute(select(Report).where(Report.id == report_id)).scalar_one()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chellow
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1752157293.0.0
|
|
4
4
|
Summary: Web Application for checking UK energy bills.
|
|
5
5
|
Project-URL: Homepage, https://github.com/WessexWater/chellow
|
|
6
6
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
@@ -22,7 +22,7 @@ Requires-Dist: pypdf==4.3.1
|
|
|
22
22
|
Requires-Dist: python-dateutil==2.8.2
|
|
23
23
|
Requires-Dist: pytz==2022.6
|
|
24
24
|
Requires-Dist: requests==2.32.4
|
|
25
|
-
Requires-Dist: sqlalchemy==2.0.
|
|
25
|
+
Requires-Dist: sqlalchemy==2.0.41
|
|
26
26
|
Requires-Dist: waitress==3.0.1
|
|
27
27
|
Requires-Dist: xlrd==2.0.1
|
|
28
28
|
Requires-Dist: zish==0.1.12
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
chellow/__init__.py,sha256=
|
|
1
|
+
chellow/__init__.py,sha256=9aoSbGmHCIHwzI_c_TLSg5CeKwqAq0I6kKaMvTrTMqg,10936
|
|
2
2
|
chellow/api.py,sha256=mk17TfweR76DPFC8lX2SArTjai6y6YshASxqO1w-_-s,11036
|
|
3
3
|
chellow/bank_holidays.py,sha256=T_utYMwe_g1dz5X-aOTdIPryg49SvB7QsWM1yphlqG8,4423
|
|
4
4
|
chellow/commands.py,sha256=ESBe9ZWj1c3vdZgqMZ9gFvYAB3hRag2R1PzOwuw9yFo,1302
|
|
@@ -13,7 +13,7 @@ chellow/rate_server.py,sha256=fg-Pf_9Hk3bXmC9riPQNGQxBvLvBa_WtNYdwDCjnCSg,5678
|
|
|
13
13
|
chellow/rrun.py,sha256=1Kt2q_K9UoDG_nsZz-Q6XJiMNKroWqlqFdxn2M6Q8CA,2088
|
|
14
14
|
chellow/testing.py,sha256=Dj2c1NX8lVlygueOrh2eyYawLW6qKEHxNhXVVUaNRO0,3637
|
|
15
15
|
chellow/utils.py,sha256=i3GQK9MIcweosZk2gi-nX_IFq2DxURAJDyNoLBg6YwM,19421
|
|
16
|
-
chellow/views.py,sha256=
|
|
16
|
+
chellow/views.py,sha256=fPCuYTWXAAWnu1Cwt4Dk3k7PHNj9gw9HeQRiXgRIn60,85459
|
|
17
17
|
chellow/e/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
chellow/e/aahedc.py,sha256=d2usudp7KYWpU6Pk3fal5EQ47EbvkvKeaFGylnb3NWw,606
|
|
19
19
|
chellow/e/bill_importer.py,sha256=7UcnqNlKbJc2GhW9gy8sDp9GuqambJVpZLvbafOZztA,7411
|
|
@@ -385,6 +385,6 @@ chellow/templates/g/supply_note_edit.html,sha256=b8mB6_ucBwoljp03iy6AgVaZUhGw3-1
|
|
|
385
385
|
chellow/templates/g/supply_notes.html,sha256=6epNmZ3NKdXZz27fvmRUGeffg_oc1kmwuBeyRzQe3Rg,854
|
|
386
386
|
chellow/templates/g/unit.html,sha256=KouNVU0-i84afANkLQ_heJ0uDfJ9H5A05PuLqb8iCN8,438
|
|
387
387
|
chellow/templates/g/units.html,sha256=p5Nd-lAIboKPEOO6N451hx1bcKxMg4BDODnZ-43MmJc,441
|
|
388
|
-
chellow-
|
|
389
|
-
chellow-
|
|
390
|
-
chellow-
|
|
388
|
+
chellow-1752157293.0.0.dist-info/METADATA,sha256=S0nWf4zPYt2hZc-NcDohJIhNlMhJ2znB8-4HgEdStE8,12585
|
|
389
|
+
chellow-1752157293.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
390
|
+
chellow-1752157293.0.0.dist-info/RECORD,,
|
|
File without changes
|