I’m still working on this.
Currently having a challenge converting the node.js signature validation to php.
Has anyone done this?
Node.js
/**
* Verifies that the request is actually from SmartThings.
* @returns true if verified, false otherwise.
*/
function signatureIsVerified(req) {
// WARNING: DO NOT USE THIS IN PRODUCTION
// We will read the public key from FS everytime we need to verify
// COMMENT OUT THIS LINE INPRODUCTION
const publicKey = fs.readFileSync(’./config/smartthings_rsa.pub’, ‘utf8’);
// END WARNING
try {
let parsed = httpSignature.parseRequest(req);
if (!httpSignature.verifySignature(parsed, publicKey)) {
console.log(‘forbidden - failed verifySignature’);
return false;
}
} catch (error) {
console.error(error);
return false;
}
return true;
}
So I continued my work, and built a Webhook for Drupal (which is PHP). If you don’t want to use the Drupal module and are not using Symphony, etc. but you still want to develop the webhook in PHP, then you could probably still download this drupal module code, and strip it down/ use it as a starting place.