twilio_sendsms fails with an http base URL: QSYS2 basicAuth option requires HTTPS
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 75/100
Línea de trabajo
Empieza con src/twilio/publish.sql y sus opciones HTTP de twilio_sendsms; después, lee la documentación de la URL base en src/twilio/utils.sql. Usa el entorno de pruebas de IBM i 7.5 mencionado en #47 para comprobar que el servidor simulado recibe las credenciales Basic esperadas y que la función devuelve queued; confirma que la documentación advierte contra el uso de HTTP sin cifrar fuera de las pruebas locales.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
twilio_sendsms can't call an http base URL, such as a local test server. Every call fails:
SQL0443 ... HTTP_POST_VERBOSE ... BASICAUTH REQUIRES HTTPS (SQLSTATE 38501)
Cause
twilio_sendsms passes the credentials with QSYS2's basicAuth HTTP option, which IBM i only allows over HTTPS. The default Twilio URL is HTTPS, so this only shows up with a non-default base URL. #47 makes that possible by adding twilio_getbaseurl and its setters, so the toolkit can be pointed at a mock server for testing.
Fix
Build the Authorization: Basic header directly with systools.base64encode instead of using the basicAuth option. The twilio_getbaseurl docs also gain a reminder to use https outside local testing, because the credentials are then sent as-is over plain HTTP. With the default HTTPS base URL, the request is unchanged.
This was verified on IBM i 7.5 with the test harness from #47 (TwilioSendTest: the mock received the expected Basic credentials, and twilio_sendsms returned queued). The change applies on top of #47, which adds twilio_getbaseurl:
diff --git a/src/twilio/publish.sql b/src/twilio/publish.sql
index ba2ca8f..f16485d 100644
--- a/src/twilio/publish.sql
+++ b/src/twilio/publish.sql
@@ -32,7 +32,13 @@ begin
declare response_message Varchar(10000) CCSID 1208;
declare response_code int default 500;
- set http_options = json_object('basicAuth': dbsdk_v1.twilio_getsid() concat ',' concat dbsdk_v1.twilio_getauthtoken(), 'header': 'content-type,application/x-www-form-urlencoded');
+ -- The credentials are sent as an Authorization header rather than with the basicAuth option,
+ -- which QSYS2's HTTP functions only allow over HTTPS, so that a non-default base URL (such as a
+ -- local test server) can use plain HTTP. The default base URL is HTTPS.
+ set http_options = json_object('headers': json_object(
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ 'Authorization': 'Basic ' concat systools.base64encode(
+ cast(dbsdk_v1.twilio_getsid() concat ':' concat dbsdk_v1.twilio_getauthtoken() as varchar(2001) ccsid 1208))));
set fullUrl = dbsdk_v1.twilio_getbaseurl() concat '/2010-04-01/Accounts/' concat dbsdk_v1.twilio_getsid() concat '/Messages.json';
set payload = 'To=' concat to_cell_number concat
diff --git a/src/twilio/utils.sql b/src/twilio/utils.sql
index 5a54eef..617968f 100644
--- a/src/twilio/utils.sql
+++ b/src/twilio/utils.sql
@@ -136,7 +136,8 @@ end;
-- changed, for example to route requests through a proxy or to a mock server for testing. The value
-- used is the first one that is set: the function argument, then the job setting
-- (`twilio_setbaseurlforjob`), then the user profile setting (`twilio_setbaseurlforme`), then the
--- default.
+-- default. `twilio_sendsms` sends the account SID and auth token with HTTP Basic authentication, so
+-- use an `https` base URL for anything other than local testing.
--
-- **Input parameters:**
-- - `BASEURL` (optional): A base URL to return instead of the configured one.
- Lenguaje dominante
- RPGLE
- Estrellas
- 13
- Forks
- 7
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 4
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de IBM/AI-SQL-Toolkit-IBMi
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
IBM/AI-SQL-Toolkit-IBMi#53 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 83/100
IBM/AI-SQL-Toolkit-IBMi#51 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
IBM/AI-SQL-Toolkit-IBMi#50 ·
-
bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
IBM/AI-SQL-Toolkit-IBMi#48 ·
-
bug
Dificultad 3/5 1-2 días Aptitud para principiantes 73/100
IBM/AI-SQL-Toolkit-IBMi#52 ·
Todos los issues de IBM/AI-SQL-Toolkit-IBMi
Issues similares
-
enhancement sharing & sync
Dificultad 1/5 Menos de una hora Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
-
[Adapter] Magic HourAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
HelpCode-ai/anythingmcp#1659 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
area:providers effort:S priority:P3 risk:night-watch status:ready type:docs
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
randomparity/kdive#3618 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día