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

Blacklisting invalid params in authorize url #611

Merged
merged 3 commits into from
Dec 29, 2017
Merged
Show file tree
Hide file tree
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
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