Skip to content

Commit

Permalink
Blacklisting invalid params in authorize url (#611)
Browse files Browse the repository at this point in the history
* blacklisting invalid params in authorize url

* removing tenant params
  • Loading branch information
luisrudge authored Dec 29, 2017
1 parent 308d55f commit 617b292
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/authentication/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,14 @@ Authentication.prototype.buildAuthorizeUrl = function(options) {
params.connection_scope = params.connection_scope.join(',');
}

params = objectHelper.blacklist(params, [
'username',
'popupOptions',
'domain',
'tenant',
'timeout'
]);
params = objectHelper.toSnakeCase(params, ['auth0Client']);
params = objectHelper.blacklist(params, ['username']);
params = parametersWhitelist.oauthAuthorizeParams(this.warn, params);

qString = qs.stringify(params);
Expand Down
11 changes: 11 additions & 0 deletions test/authentication/authentication.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ describe('auth0.authentication', function() {
});
});

['username', 'popupOptions', 'domain', 'tenant', 'timeout'].forEach(function(param) {
it('should remove parameter: ' + param, function() {
var options = {};
options[param] = 'foobar';
var url = this.auth0.buildAuthorizeUrl(options);
expect(url).to.be(
'https://me.auth0.com/authorize?client_id=...&response_type=code&redirect_uri=http%3A%2F%2Fpage.com%2Fcallback'
);
});
});

it('should return a url using the default settings', function() {
var url = this.auth0.buildAuthorizeUrl({ state: '1234' });

Expand Down
2 changes: 1 addition & 1 deletion test/web-auth/extensibility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('auth0.WebAuth extensibility', function() {
it('should change the content of the params', function(done) {
stub(PopupHandler.prototype, 'load', function(url, relayUrl, options, cb) {
expect(url).to.be(
'https://test.auth0.com/authorize?client_id=...&response_type=code&tenant=test&owp=true&scope=openid&redirect_uri=http%3A%2F%2Fcustom-url.com&state=randomState'
'https://test.auth0.com/authorize?client_id=...&response_type=code&owp=true&scope=openid&redirect_uri=http%3A%2F%2Fcustom-url.com&state=randomState'
);
expect(relayUrl).to.be('https://test.auth0.com/relay.html');
expect(options).to.eql({});
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 @@ -92,7 +92,7 @@ describe('auth0.WebAuth.popup', function() {
it('should default scope to openid', function(done) {
stub(PopupHandler.prototype, 'load', function(url) {
expect(url).to.be(
'https://me.auth0.com/authorize?client_id=...&response_type=id_token&redirect_uri=http%3A%2F%2Fpage.com%2Fcallback&tenant=me&connection=the_connection&state=123&nonce=456&scope=openid'
'https://me.auth0.com/authorize?client_id=...&response_type=id_token&redirect_uri=http%3A%2F%2Fpage.com%2Fcallback&connection=the_connection&state=123&nonce=456&scope=openid'
);
storage.setItem.restore();
TransactionManager.prototype.process.restore();
Expand Down

0 comments on commit 617b292

Please sign in to comment.