chellow 1751991276.0.0__py3-none-any.whl → 1752483970.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 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.query(User).filter(User.email_address == username).first()
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
- g.sess.query(User)
138
- .filter(User.email_address == username)
139
- .first()
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
- g.sess.query(User).filter(User.email_address == email).first()
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
- g.sess.query(User)
167
- .filter(User.email_address == auth.username)
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 g.user is None or (not ad_auth_on and auth is None):
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",
@@ -51,7 +51,11 @@ ELEMENT_MAP = {
51
51
  "cfd-operational-kwh",
52
52
  ),
53
53
  "954379": ("cfd-interim-gbp", "cfd-interim-rate", "cfd-interim-kwh"),
54
- "538249": ("capacity-gbp", "capacity-rate", "capacity-kwh"),
54
+ "538249": (
55
+ "cm-settlement-levy-gbp",
56
+ "cm-settlement-levy-rate",
57
+ "cm-settlement-levy-kwh",
58
+ ),
55
59
  "568307": ("capacity-gbp", "capacity-rate", "capacity-kwh"),
56
60
  },
57
61
  },
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: 1751991276.0.0
3
+ Version: 1752483970.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.30
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=yBjAoOWh4NlA847_j4hiI7O6YyiEysf2X1y873JS-aA,9792
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=7nk7kZALoSGeyMSVU-_DzYSLt7ypPFQ6zBpx8--AER4,85354
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
@@ -50,7 +50,7 @@ chellow/e/bill_parsers/activity_mop_stark_xlsx.py,sha256=opjXRrqrgBTbSKzL0JfTLP0
50
50
  chellow/e/bill_parsers/annual_mop_stark_xlsx.py,sha256=-HMoIfa_utXYKA44RuC0Xqv3vd2HLeQU_4P0iBUd3WA,4219
51
51
  chellow/e/bill_parsers/bgb_edi.py,sha256=GuwHeYbAGk7BVg5n19FcTANFDyKI-y0z3f9niQaPSSw,4828
52
52
  chellow/e/bill_parsers/csv.py,sha256=U5zcIaZ6B5QTTpFDAcBnk4G2r8B3j5kJhDPL4AJNkEk,5640
53
- chellow/e/bill_parsers/drax_edi.py,sha256=TC_vlBLn_elmIZrug-vqVRjUcrd7U2fDO75PTzwmcEY,15091
53
+ chellow/e/bill_parsers/drax_edi.py,sha256=vAVH8nnHqkwacmHiP88vFGHBKlH9k59YIf1G-7P05Yg,15184
54
54
  chellow/e/bill_parsers/drax_element_edi.py,sha256=kxjg1KA4UheMa8doGp9skXtQYrNK8Eisy9ksafR5TQo,13661
55
55
  chellow/e/bill_parsers/edf_export_xlsx.py,sha256=J4lY8epiSTIePZ6D1SGD76TXRoev35KrUC2sjHkNqlE,6632
56
56
  chellow/e/bill_parsers/engie_edi.py,sha256=PDMDI0aqUM1lalgzxih1YmMho11n1rMqE0vyL-aEIs8,15840
@@ -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-1751991276.0.0.dist-info/METADATA,sha256=3ZCeJU6ewzdHi69KcwtbjlustTVdKbO5HcmRUZQueHM,12585
389
- chellow-1751991276.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
390
- chellow-1751991276.0.0.dist-info/RECORD,,
388
+ chellow-1752483970.0.0.dist-info/METADATA,sha256=2YZ1h5mTfgfRUr2ArLYeDbtIli2e5Mbvn5TaFKA1PY8,12585
389
+ chellow-1752483970.0.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
390
+ chellow-1752483970.0.0.dist-info/RECORD,,