File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
lib/passport-http-oauth/strategies Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -293,6 +293,15 @@ ConsumerStrategy.prototype.authenticate = function(req) {
293293 if ( tokenSecret ) { key += utils . encode ( tokenSecret ) ; }
294294 var computedSignature = utils . hmacsha1 ( key , base ) ;
295295
296+ if ( signature !== computedSignature ) {
297+ return self . fail ( self . _challenge ( 'signature_invalid' ) ) ;
298+ }
299+
300+ } else if ( signatureMethod === 'HMAC-SHA256' ) {
301+ var key = consumerSecret + '&' ;
302+ if ( tokenSecret ) { key += tokenSecret ; }
303+ var computedSignature = utils . hmacsha256 ( key , base ) ;
304+
296305 if ( signature !== computedSignature ) {
297306 return self . fail ( self . _challenge ( 'signature_invalid' ) ) ;
298307 }
Original file line number Diff line number Diff line change @@ -185,6 +185,18 @@ exports.hmacsha1 = function(key, text) {
185185 return crypto . createHmac ( 'sha1' , key ) . update ( text ) . digest ( 'base64' )
186186}
187187
188+ /**
189+ * Generate HMAC-SHA256 signature.
190+ *
191+ * @param {String } key
192+ * @param {String } text
193+ * @return {String }
194+ * @api private
195+ */
196+ exports . hmacsha256 = function ( key , text ) {
197+ return crypto . createHmac ( 'sha256' , key ) . update ( text ) . digest ( 'base64' )
198+ }
199+
188200/**
189201 * Generate PLAINTEXT signature.
190202 *
You can’t perform that action at this time.
0 commit comments