File tree 2 files changed +20
-0
lines changed
lib/passport-http-oauth/strategies
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -302,6 +302,14 @@ ConsumerStrategy.prototype.authenticate = function(req) {
302
302
if ( tokenSecret ) { key += utils . encode ( tokenSecret ) ; }
303
303
var computedSignature = utils . hmacsha256 ( key , base ) ;
304
304
305
+ if ( signature !== computedSignature ) {
306
+ return self . fail ( self . _challenge ( 'signature_invalid' ) ) ;
307
+ }
308
+ } else if ( signatureMethod === 'RSA-SHA1' ) {
309
+ var key = utils . encode ( consumerSecret ) + '&' ;
310
+ if ( tokenSecret ) { key += utils . encode ( tokenSecret ) ; }
311
+ var computedSignature = utils . rsasha1 ( key , base ) ;
312
+
305
313
if ( signature !== computedSignature ) {
306
314
return self . fail ( self . _challenge ( 'signature_invalid' ) ) ;
307
315
}
Original file line number Diff line number Diff line change @@ -198,6 +198,18 @@ exports.hmacsha256 = function(key, text) {
198
198
return crypto . createHmac ( 'sha256' , key ) . update ( text ) . digest ( 'base64' )
199
199
}
200
200
201
+ /**
202
+ * Generate RSA-SHA1 signature.
203
+ *
204
+ * @param {String } key
205
+ * @param {String } text
206
+ * @return {String }
207
+ * @api private
208
+ */
209
+ exports . rsasha1 = function ( key , text ) {
210
+ return crypto . createSign ( 'RSA-SHA1' ) . update ( text ) . sign ( key , 'base64' )
211
+ }
212
+
201
213
/**
202
214
* Generate PLAINTEXT signature.
203
215
*
You can’t perform that action at this time.
0 commit comments