Compare commits

..
Author SHA1 Message Date
Lukas Bockstaller e4b65ba49d drop pycrytodome as a dependency from pyproject.toml 2026-11-18 14:53:01 +01:00
Lukas Bockstaller 071b8baf61 remove temporary test & Crypto from test_oidc_op.py 2026-11-18 14:51:22 +01:00
Lukas Bockstaller ff6922e2ce remove Crypto from test_oidc_op.py::test_keys_endpoint
switch out Crypto.PublicKey.RSA with
cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicNumbers in test_keys_endopoint
2026-11-18 14:48:32 +01:00
Lukas Bockstaller 428d28e744 remove Crypto from oidc_op.py
switch out Crypto.PublicKey.RSA with
cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey and from cryptography.hazmat.primitives.serialization.load_pem_public_key which we already need
2026-11-18 14:42:35 +01:00
Lukas Bockstaller 0de0ad6cae add temporary test to show that Crypto.RSA and cryptography...RSAPublicKey produce identical output 2026-11-18 14:39:57 +01:00
Lukas Bockstaller 7f046e16a2 fix: pass request object to the request parameter of the form (#6786) 2026-11-18 12:04:34 +01:00
5 changed files with 21 additions and 12 deletions

No files matched your search

-1
View File
@@ -80,7 +80,6 @@ dependencies = [
"psycopg2-binary",
"pycountry",
"pycparser==3.12",
"pycryptodome==3.24.*",
"pypdf==6.21.*",
"python-bidi==0.6.*", # Support for Arabic in reportlab
"python-dateutil==4.0.*",
+2 -3
View File
@@ -256,9 +256,8 @@ def reorder_discounts(request, organizer, event):
ids = json.loads(request.body.decode('utf-8'))['ids']
except (JSONDecodeError, KeyError, ValueError):
return HttpResponseBadRequest("expected JSON: {ids:[]}")
ids = [int(i) for i in ids if isinstance(i, int) or i.isdigit()]
input_discounts = list(request.event.discounts.filter(id__in=ids))
input_discounts = list(request.event.discounts.filter(id__in=[i for i in ids if i.isdigit()]))
if len(input_discounts) != len(ids):
raise Http404(_("Some of the provided object ids are invalid."))
@@ -267,7 +266,7 @@ def reorder_discounts(request, organizer, event):
raise Http404(_("Not all discounts have been selected."))
for c in input_discounts:
pos = ids.index(c.pk)
pos = ids.index(str(c.pk))
if pos != c.position: # Save unneccessary UPDATE queries
c.position = pos
c.save(update_fields=['position'])
+1 -1
View File
@@ -267,7 +267,7 @@ class CustomerStep(CartMixin, TemplateFlowStep):
else None
),
prefix='login',
request=self.request.event,
request=self.request,
)
for field in f.fields.values():
field._show_required = field.required
+7 -4
View File
@@ -26,7 +26,8 @@ from binascii import unhexlify
from datetime import timedelta
from urllib.parse import parse_qs, urlencode, urlparse, urlunparse
from Crypto.PublicKey import RSA
from cryptography.hazmat.primitives.asymmetric.rsa import RSAPublicKey
from cryptography.hazmat.primitives.serialization import load_pem_public_key
from django.db import transaction
from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import redirect, render
@@ -498,7 +499,9 @@ class KeysView(View):
def get(self, request, *args, **kwargs):
privkey, pubkey = _get_or_create_server_keypair(request.organizer)
kid = hashlib.sha256(pubkey.encode()).hexdigest()[:16]
pubkey = RSA.import_key(pubkey)
public_key = load_pem_public_key(pubkey.encode())
assert isinstance(public_key, RSAPublicKey)
public_numbers = public_key.public_numbers()
return JsonResponse({
'keys': [
@@ -507,8 +510,8 @@ class KeysView(View):
'alg': 'RS256',
'kid': kid,
'use': 'sig',
'e': self._encode_int(pubkey.e).decode().rstrip("="),
'n': self._encode_int(pubkey.n).decode().rstrip("="),
'e': self._encode_int(public_numbers.e).decode().rstrip("="),
'n': self._encode_int(public_numbers.n).decode().rstrip("="),
}
]
})
+11 -3
View File
@@ -30,7 +30,10 @@ from urllib.parse import quote
import jwt
import pytest
from bs4 import BeautifulSoup
from Crypto.PublicKey import RSA
from cryptography.hazmat.primitives.asymmetric.rsa import (
RSAPublicKey, RSAPublicNumbers,
)
from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat
from django.utils.timezone import now
from django_scopes import scopes_disabled
from freezegun import freeze_time
@@ -691,6 +694,11 @@ def test_keys_endpoint(env, client, ssoclient):
e = decode_int(data['keys'][0]['e'])
n = decode_int(data['keys'][0]['n'])
pubkey = RSA.construct((n, e))
representation = pubkey.export_key('PEM').decode()
pubkey = RSAPublicNumbers(e, n).public_key()
assert isinstance(pubkey, RSAPublicKey)
representation = pubkey.public_bytes(
Encoding.PEM, PublicFormat.SubjectPublicKeyInfo
).decode()
assert representation.strip() == env[0].settings.sso_server_signing_key_rsa256_public.strip()