diff --git a/authentication/migrations/0003_add_helptext_to_keycloak_token_fields.py b/authentication/migrations/0003_add_helptext_to_keycloak_token_fields.py new file mode 100644 index 00000000..187767f9 --- /dev/null +++ b/authentication/migrations/0003_add_helptext_to_keycloak_token_fields.py @@ -0,0 +1,26 @@ +# Generated by Django 4.2.10 on 2024-03-06 20:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("authentication", "0002_add_keycloak_user_info_model"), + ] + + operations = [ + migrations.AlterField( + model_name="keycloakadmintoken", + name="authorization_token_expires_in", + field=models.IntegerField( + help_text="Seconds until authentication token expires" + ), + ), + migrations.AlterField( + model_name="keycloakadmintoken", + name="refresh_token_expires_in", + field=models.IntegerField( + help_text="Seconds until refresh token expires", null=True + ), + ), + ] diff --git a/system_meta/views.py b/system_meta/views.py index dac80610..cbda5d83 100644 --- a/system_meta/views.py +++ b/system_meta/views.py @@ -52,8 +52,10 @@ def apisix_test_request(request): response = { "name": "Response ok!", "user": request.user.username if request.user is not None else None, - "x_userinfo": decode_x_header(request, "HTTP_X_USERINFO"), - "x_id_token": decode_x_header(request, "HTTP_X_ID_TOKEN"), + "x_userinfo": decode_x_header(request, "HTTP_X_USERINFO") + or "No HTTP_X_USERINFO header", + "x_id_token": decode_x_header(request, "HTTP_X_ID_TOKEN") + or "No HTTP_X_ID_TOKEN header", } return Response(response, status=status.HTTP_200_OK) diff --git a/unified_ecommerce/middleware.py b/unified_ecommerce/middleware.py index cf1d1a61..3c4ca088 100644 --- a/unified_ecommerce/middleware.py +++ b/unified_ecommerce/middleware.py @@ -19,6 +19,9 @@ def decode_apisix_headers(self, request): try: apisix_result = decode_x_header(request, "HTTP_X_USERINFO") if not apisix_result: + log.debug( + "No APISIX-specific header found", + ) return None except json.JSONDecodeError: log.debug( diff --git a/unified_ecommerce/utils.py b/unified_ecommerce/utils.py index ba9defa5..a5688ddb 100644 --- a/unified_ecommerce/utils.py +++ b/unified_ecommerce/utils.py @@ -326,7 +326,7 @@ def decode_x_header(request, header): x_userinfo = request.META.get(header, False) if not x_userinfo: - return f"No {header} header" + return None decoded_x_userinfo = base64.b64decode(x_userinfo) return json.loads(decoded_x_userinfo)