Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoResolveCallback property to disabled auto attach the origin url to the callbackUrl #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions lib/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ var passport = require('passport-strategy')
*
* Options:
*
* - `authorizationURL` URL used to obtain an authorization grant
* - `tokenURL` URL used to obtain an access token
* - `clientID` identifies client to service provider
* - `clientSecret` secret used to establish ownership of the client identifer
* - `callbackURL` URL to which the service provider will redirect the user after obtaining authorization
* - `passReqToCallback` when `true`, `req` is the first argument to the verify callback (default: `false`)
* - `authorizationURL` URL used to obtain an authorization grant
* - `tokenURL` URL used to obtain an access token
* - `clientID` identifies client to service provider
* - `clientSecret` secret used to establish ownership of the client identifer
* - `callbackURL` URL to which the service provider will redirect the user after obtaining authorization
* - `autoResolveCallback` whether to attach the origin url to the callbackUrl when using relative url (default: `true`)
* - `passReqToCallback` when `true`, `req` is the first argument to the verify callback (default: `false`)
*
* Examples:
*
Expand Down Expand Up @@ -96,6 +97,7 @@ function OAuth2Strategy(options, verify) {
'', options.authorizationURL, options.tokenURL, options.customHeaders);

this._callbackURL = options.callbackURL;
this._autoResolveCallback = options.autoResolveCallback !== false;
this._scope = options.scope;
this._scopeSeparator = options.scopeSeparator || ' ';
this._pkceMethod = (options.pkce === true) ? 'S256' : options.pkce;
Expand Down Expand Up @@ -139,7 +141,7 @@ OAuth2Strategy.prototype.authenticate = function(req, options) {
}

var callbackURL = options.callbackURL || this._callbackURL;
if (callbackURL) {
if (callbackURL && this._autoResolveCallback) {
var parsed = url.parse(callbackURL);
if (!parsed.protocol) {
// The callback URL is relative, resolve a fully qualified URL from the
Expand Down