FINTLabs / nam-smstoken

SMS token authentication class for NetIQ Access Manager
0 stars 3 forks source link

gatewaySuccess #1

Open demesg opened 6 years ago

demesg commented 6 years ago

Hi, My SMS gateway returns a message ID in text, like this: SMS gateway output: 1097205267 Would it be possible to check the response header or do a regexp match instead of string match ?

btw thank you for making this public . regards Magnus

fsjovatsen commented 6 years ago

Hi @demesg ,

sorry that I haven't respond earlier. I will look into this.

If we gone add support for checking the response header, do you have any example of an response to check for?

fs

demesg commented 6 years ago

Hi

This is from idp log: INFO no.rogfk.nam.idp.utils.Tracer - Mobile: +46xxxxxxxxx INFO no.rogfk.nam.idp.utils.Tracer - SMS gateway request: https://api.smsteknik.se/send/ user=xx&pass=xx&to=xx&text=xx&id=xx INFO no.rogfk.nam.idp.utils.Tracer - SMS gateway output: 1108544569 INFO no.rogfk.nam.idp.utils.Tracer - The reponse from the gateway is uknown

The response from SMS service is a message id and in my case always numbers, but a regexp would work ..

Thank you! // Magnus

jarlehansen commented 6 years ago

I have added a possible fix for this in the gateway-success-regex branch. To keep backwards compatibility I have made sure that if no changes are done to the existing config it will still use "contains". If the property gatewaySuccessRegex is set to true (by default this is false, even if the property is null), it will instead use "matches". Take a look at the Config class here for the details: https://github.com/Rogaland/nam-smstoken/blob/gateway-success-regex/src/main/java/no/rogfk/nam/idp/smsgateway/Config.java Specifically the matchesGatewaySuccess and matchesGatewayError methods.

The same has been done with the gatewayError to keep consistency. Will this solve your problem? If you have a better suggestion, just let me know.

demesg commented 6 years ago

Nice solution , I think it fits my needs , but I'm not able to do code review or compile, but I can test if I get the jar file. .

fsjovatsen commented 6 years ago

Hi,

can you test with this jar?

nam-smstoken-1.2.0-beta.jar.zip

demesg commented 6 years ago

It worked perfectly, but I were only able to do positive tests, I were not able to make the sms gateway to produce an error response.

A small addition to the documentation may also be good: "String to look for in the gateway respone if the gateway successfully sent the SMS" to: "String or regular expression to look for ...."

Thank you very much! Magnus

jarlehansen commented 6 years ago

Thanks for the feedback @demesg, I will update the readme and I am also in the process of improving the unit tests. When this is complete we will do a final release of version 1.2.0.

jarlehansen commented 6 years ago

Created pull request to get the code merged into master https://github.com/Rogaland/nam-smstoken/pull/2