From 93923f25aaae2e838fe2ddab184f6c4e1ec4331e Mon Sep 17 00:00:00 2001 From: alorig <220087330+alorig@users.noreply.github.com> Date: Mon, 24 Nov 2025 07:45:45 +0500 Subject: [PATCH] Require API key for WordPress integration auth Updated the WordPress integration validation to require an API key as the sole authentication method, removing support for username and application password authentication. --- .../igny8_core/modules/integration/views.py | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/backend/igny8_core/modules/integration/views.py b/backend/igny8_core/modules/integration/views.py index 8246c81e..6266e323 100644 --- a/backend/igny8_core/modules/integration/views.py +++ b/backend/igny8_core/modules/integration/views.py @@ -58,28 +58,19 @@ class IntegrationViewSet(SiteSectorModelViewSet): def validate(self, data): """ Custom validation for WordPress integrations. - Allow API key-only authentication (no username/password required). + API key is the only required authentication method. """ validated_data = super().validate(data) - # For WordPress platform, allow API key-only authentication + # For WordPress platform, require API key only if validated_data.get('platform') == 'wordpress': credentials = validated_data.get('credentials_json', {}) - # If API key is provided, username/app_password are optional - if credentials.get('api_key'): - # API key authentication - no username/password required - pass - elif not credentials.get('username') or not credentials.get('app_password'): - # Traditional auth requires both username and app_password - if not credentials.get('username'): - raise serializers.ValidationError({ - 'credentials_json': 'Username is required when not using API key authentication.' - }) - if not credentials.get('app_password'): - raise serializers.ValidationError({ - 'credentials_json': 'Application password is required when not using API key authentication.' - }) + # API key is required for all WordPress integrations + if not credentials.get('api_key'): + raise serializers.ValidationError({ + 'credentials_json': 'API key is required for WordPress integration.' + }) return validated_data