Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added the customSigner option. #703

Closed
wants to merge 1 commit into from

2 participants

@trcjr

The customSigner allows more flexibility in signing requests.

@trcjr trcjr Added the customSigner option.
The customSigner allows more flexibility in signing requests.
992188a
@mikeal
Owner

no longer merges cleanly :(

@mikeal mikeal closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 11, 2013
  1. @trcjr

    Added the customSigner option.

    trcjr authored
    The customSigner allows more flexibility in signing requests.
This page is out of date. Refresh to see the latest.
Showing with 19 additions and 0 deletions.
  1. +1 −0  README.md
  2. +18 −0 request.js
View
1  README.md
@@ -202,6 +202,7 @@ The first argument can be either a `url` or an `options` object. The only requir
* `aws` - `object` containing AWS signing information. Should have the properties `key`, `secret`. Also requires the property `bucket`, unless you’re specifying your `bucket` as part of the path, or the request doesn’t use a bucket (i.e. GET Services)
* `httpSignature` - Options for the [HTTP Signature Scheme](https://github.com/joyent/node-http-signature/blob/master/http_signing.md) using [Joyent's library](https://github.com/joyent/node-http-signature). The `keyId` and `key` properties must be specified. See the docs for other options.
* `localAddress` - Local interface to bind for network connections.
+* `customSigner` - `object` that defines the method `sign(request)`. Should do whatever is necessary to modify `request` to be signed.
The callback argument gets 3 arguments:
View
18 request.js
@@ -264,6 +264,10 @@ Request.prototype.init = function (options) {
self.oauth(options.oauth)
}
+ if (options.customSigner) {
+ self.customSigner( options.customSigner );
+ }
+
if (options.aws) {
self.aws(options.aws)
}
@@ -570,6 +574,11 @@ Request.prototype.start = function () {
if (self.src && self.src.stat && self.src.stat.size && !self.hasHeader('content-length')) {
self.setHeader('content-length', self.src.stat.size)
}
+
+ if (self._customSigner) {
+ self.customSigner(self._customSigner, true);
+ }
+
if (self._aws) {
self.aws(self._aws, true)
}
@@ -1057,6 +1066,15 @@ Request.prototype.auth = function (user, pass, sendImmediately) {
}
return this
}
+
+Request.prototype.customSigner = function (customSigner, now) {
+ if (!now) {
+ this._customSigner = customSigner;
+ return this;
+ }
+ this._customSigner.sign(this);
+ return this
+}
Request.prototype.aws = function (opts, now) {
if (!now) {
this._aws = opts
Something went wrong with that request. Please try again.