Skip to content

Commit

Permalink
Updated how and where this Passport Strategy links to.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Lochrie committed Nov 27, 2012
1 parent 1736ad3 commit 9799e23
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
Add "passport-signature" to your `package.json` file. Then, `(sudo) npm install -l`.

## Config
Go into `lib/passport-signature/strategy` and update the server base URL to reflect whatever URL you are using or testing against.
In the latest version, this module has been updated to use an `app` variable for the URLs for the
Signature OAuth app. You can do something like:

*TODO*: Signature URL could be an `environment[.js]` variable.
app.set('sigAuthDomain', 'http://localhost...')

The _only_ reason that you would want to do this is if you were testing OAuth against another OAuth Server.
If in doubt, don't set the `app` variable above.

## Notes
Tested against the `example` project in [this](https://github.com/jaredhanson/oauth2orize) OAUTH2 provider repo.
Expand All @@ -15,4 +19,4 @@ Tested against the `example` project in [this](https://github.com/jaredhanson/oa
[Jared Hanson](https://github.com/jaredhanson/)

###License
MIT
MIT
11 changes: 8 additions & 3 deletions lib/passport-signature/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ var util = require('util')
*/
function Strategy(options, verify) {
options = options || {};
options.authorizationURL = options.authorizationURL || 'http://some-url-tbd.com/dialog/authorize';
options.tokenURL = options.tokenURL || 'http://some-url-tbd.com/oauth/token';
sigAuthDomain = 'http://some-url-tbd.com';
profileURL = (app._locals.settings['sigAuthDomain']) ? app._locals.settings['sigAuthDomain'] : sigAuthDomain;
options.authorizationURL = profileURL + '/dialog/authorize';
options.tokenURL = profileURL + '/oauth/token';
options.scopeSeparator = options.scopeSeparator || ',';

OAuth2Strategy.call(this, options, verify);
Expand Down Expand Up @@ -76,7 +78,10 @@ Strategy.prototype.authorizationParams = function (options) {
* @api protected
*/
Strategy.prototype.userProfile = function(accessToken, done) {
this._oauth2.getProtectedResource('http://some-url-tbd.com/api/userinfo', accessToken, function (err, body, res) {
sigAuthDomain = 'http://some-url-tbd.com';
profileURL = (app._locals.settings['sigAuthDomain']) ? app._locals.settings['sigAuthDomain'] : sigAuthDomain;
profileURL += '/api/userinfo';
this._oauth2.getProtectedResource(profileURL, accessToken, function (err, body, res) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }

try {
Expand Down
Binary file removed passport-signature-0.0.1.tgz
Binary file not shown.

0 comments on commit 9799e23

Please sign in to comment.