netzbegruenung / keycloak-mfa-plugins

Keycloak plugins for MFA (enforce MFA, SMS authentication step, native app integration)
Apache License 2.0
61 stars 15 forks source link

Receiver Phone Number Attribute - GatewayAPI.com requires an array #100

Open davidezordan25 opened 1 month ago

davidezordan25 commented 1 month ago

Hi, I'm trying to implement your solution using our subscription to gatewayapi.com. According to their documentation (https://gatewayapi.com/docs/apis/rest/#basic-use), for the "Receiver Phone Number Attribute," they use "recipients" as an array of receivers. I've tried both "recipients" and "recipients.0.msisdn", but I received the following errors respectively:

2024-07-15 15:54:12,308 ERROR [netzbegruenung.keycloak.authenticator.gateway.SmsServiceFactory] (executor-thread-17) Failed to send message to 346xxxxxx [Response: {"fields":{"recipients":[{"sequencetypeinvalid":"Expected a list"}]}} ]. Validate your config.

2024-07-15 15:56:35,849 ERROR [netzbegruenung.keycloak.authenticator.gateway.SmsServiceFactory] (executor-thread-17) Failed to send message to 346xxxx [Response: {"fields":{"recipients":[{"requiredfieldinvalid":"Required key not provided"}]

melegiul commented 1 month ago

For the moment this API is not supported unfortunately, because it is not possible to send receivers as array. I guess we can further improve here, so that users can choose to send receivers as strings or as array. But we should still support the strings too, because there are providers that require them like: https://www.gtx-messaging.com/en/api-docs/sms-rest-api/

Related to: https://github.com/netzbegruenung/keycloak-mfa-plugins/issues/67

davidezordan25 commented 4 weeks ago

As a workaround, i managed to make it compatible with the GatewayApi.com using the following configuration:

Besides, I also had to slightly modify in my local clone Java code in ApiSmsService.java in the prefix handling since GatewaySMS needs prefix in the format "39" e.g. for Italy, without + or other formats.