How to use the http-signature.verifySignature function in http-signature

To help you get started, we’ve selected a few http-signature examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github request / request / tests / test-http-signature.js View on Github external
var server = http.createServer(function (req, res) {
  var parsed = httpSignature.parseRequest(req)
  var publicKeyPEM = publicKeyPEMs[parsed.keyId]
  var verified = httpSignature.verifySignature(parsed, publicKeyPEM)
  res.writeHead(verified ? 200 : 400)
  res.end()
})
github SmartThingsCommunity / smartapp-sdk-nodejs / lib / util / signature.js View on Github external
signatureIsVerified(req) {
		try {
			const parsed = httpSignature.parseRequest(req)
			if (!httpSignature.verifySignature(parsed, publicKey)) {
				console.error('Forbidden - failed verifySignature')
				return false
			}
		} catch (error) {
			console.error(error)
			return false
		}

		return true
	}
}
github SmartThingsCommunity / smartapp-sdk-nodejs / lib / util / authorizer.js View on Github external
async isAuthorized(req) {
		try {
			const keyResolver = this._keyResolver
			const parsed = httpSignature.parseRequest(req, undefined)
			const publicKey = await keyResolver.getKey(parsed.keyId)

			if (httpSignature.verifySignature(parsed, publicKey)) {
				return true
			}

			this._logger.error('Forbidden - failed verifySignature')
			return false
		} catch (error) {
			this._logger.exception(error)
			return false
		}
	}
}

http-signature

Reference implementation of Joyent's HTTP Signature scheme.

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis