fix: sso api validator fix (#30732)

This commit is contained in:
Alexander J Sheehan
2022-07-15 10:51:38 -04:00
committed by GitHub
parent 36e5bd6b35
commit 0b28141b9e

View File

@@ -22,11 +22,12 @@ class SAMLProviderConfigSerializer(serializers.ModelSerializer): # lint-amnesty
# are not archived, raise a validation error. We do this to prevent provider configs from sharing entity ID's
# which link a provider config to provider data (SAML certificates). An entity ID therefore, is uniquely linked
# to a single slug/provider config (which in the case of enterprise provider slug == customer slug).
if SAMLProviderConfig.objects.current_set().filter(
entity_id=data['entity_id'],
archived=False,
).exclude(slug=data['slug']):
raise serializers.ValidationError(f"Entity ID: {data['entity_id']} already taken")
if data.get('entity_id'):
if SAMLProviderConfig.objects.current_set().filter(
entity_id=data['entity_id'],
archived=False,
).exclude(slug=data['slug']):
raise serializers.ValidationError(f"Entity ID: {data['entity_id']} already taken")
return data
def create(self, validated_data):