Skip to content

Commit

Permalink
Merge pull request #336 from auth0/fix-redirecturi-popup
Browse files Browse the repository at this point in the history
popup.authorize should not require redirectURI when using OWP
  • Loading branch information
hzalaz authored Jan 30, 2017
2 parents 6c98ce0 + 9416847 commit bbc6e50
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ <h2>Console:</h2>
e.preventDefault();

webAuth.popup.loginWithCredentials({
connection: 'tests',
connection: 'acme',
username: $('.popup-login-username').val(),
password: $('.popup-login-password').val(),
scope: 'openid',
Expand Down
2 changes: 1 addition & 1 deletion src/authentication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Authentication.prototype.buildAuthorizeUrl = function (options) {
/* eslint-disable */
assert.check(params, { type: 'object', message: 'options parameter is not valid' }, {
clientID: { type: 'string', message: 'clientID option is required' },
redirectUri: { type: 'string', message: 'redirectUri option is required' },
redirectUri: { optional: true, type: 'string', message: 'redirectUri option is required' },
responseType: { type: 'string', message: 'responseType option is required' },
nonce: { type: 'string', message: 'nonce option is required', condition: function(o) {
return o.responseType.indexOf('code') === -1 && o.responseType.indexOf('id_token') !== -1;
Expand Down
5 changes: 3 additions & 2 deletions src/web-auth/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,19 @@ Popup.prototype.authorize = function (options, cb) {
responseType: { type: 'string', message: 'responseType option is required' }
});

relayUrl = urljoin(this.baseOptions.rootUrl, 'relay.html');

// used by server to render the relay page instead of sending the chunk in the
// url to the callback
params.owp = true;
params.redirectUri = undefined;

params = this.transactionManager.process(params);

url = this.client.buildAuthorizeUrl(params);

popup = this.getPopupHandler(options);

relayUrl = urljoin(this.baseOptions.rootUrl, 'relay.html');

return popup.load(url, relayUrl, {}, responseHandler(cb));
};

Expand Down
2 changes: 1 addition & 1 deletion test/web-auth/popup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('auth0.WebAuth.popup', function () {

it('should open the authorize page in a popup', function (done) {
stub(PopupHandler.prototype, 'load', function(url, relayUrl, options, cb) {
expect(url).to.be('https://me.auth0.com/authorize?client_id=...&response_type=id_token&redirect_uri=http%3A%2F%2Fpage.com%2Fcallback&connection=the_connection&nonce=123&state=456&owp=true');
expect(url).to.be('https://me.auth0.com/authorize?client_id=...&response_type=id_token&connection=the_connection&nonce=123&state=456&owp=true');
expect(relayUrl).to.be('https://me.auth0.com/relay.html');
expect(options).to.eql({});
cb(null, {
Expand Down

0 comments on commit bbc6e50

Please sign in to comment.