OIDC: Do not expect uid to be string

This commit is contained in:
Raphael Michel
2024-03-12 10:52:09 +01:00
parent 3f31843fd1
commit 2c7ada6e86

View File

@@ -720,7 +720,7 @@ class SSOLoginReturnView(RedirectBackMixin, View):
raise Http404("Unknown SSO method.")
identifier = hashlib.sha256(
profile['uid'].encode() + b'@' + str(self.provider.pk).encode()
str(profile['uid']).encode() + b'@' + str(self.provider.pk).encode()
).hexdigest().upper()[:settings.ENTROPY['customer_identifier']]
if "1" not in identifier and "0" not in identifier:
# This is a hack to make sure the hash space does not overlap with the random identifiers generated by
@@ -753,7 +753,7 @@ class SSOLoginReturnView(RedirectBackMixin, View):
customer = Customer(
organizer=self.request.organizer,
identifier=identifier,
external_identifier=profile['uid'],
external_identifier=str(profile['uid']),
provider=self.provider,
email=profile['email'],
phone=profile.get('phone') or None,
@@ -767,7 +767,7 @@ class SSOLoginReturnView(RedirectBackMixin, View):
customer_created.send(customer.organizer, customer=customer)
customer.log_action('pretix.customer.created', user=self.request.user, data=dict(
identifier=identifier,
external_identifier=profile['uid'],
external_identifier=str(profile['uid']),
provider=self.provider.pk,
email=profile['email'],
phone=profile.get('phone') or None,
@@ -806,7 +806,7 @@ class SSOLoginReturnView(RedirectBackMixin, View):
'_source': 'provider'
})
if customer.external_identifier != profile['uid']:
if customer.external_identifier != str(profile['uid']):
return self._fail(
_('Login was not successful. Error message: "{error}".').format(
error='identifier not unique',