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

getSSOData should call /ssodata from the ULP #733

Merged
merged 3 commits into from
Apr 6, 2018
Merged

Conversation

luisrudge
Copy link
Contributor

currently, lock does this already, but auth0.js will always use checkSession, which is not supported in the ULP. This PR adds compatibility to the ULP when you want to call getssodata.

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see you're still refering to HLP instead of ULP in the code. Should this be changed? (var names, test descriptions, etc)

var url;
var params = '';

if (typeof withActiveDirectories === 'function') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this getSSOData is a new function, isn't it better to flip the parameters order instead of doing this replacement?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to be the same signature as v8: https://github.com/auth0/auth0.js/blob/v8/src/authentication/index.js#L356

also, callbacks should always be the last argument

params =
'?' +
qs.stringify({
ldaps: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does this 1 mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what does passing this parameter do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what the ssodata endpoint does with this param


url = urljoin(this.baseOptions.rootUrl, 'user', 'ssodata', params);

return this.request.get(url, { noHeaders: true }).withCredentials().end(responseHandler(cb));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why noHeaders=true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but what does passing this parameter do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also removing the telemetry header.. What's the reason for not sending any headers now? I know you copied this from another project, but I need a reason not to add it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably because we don't want to track ssodata? I don't know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cocojoe after the discussion we had today regarding tracking, is this something you want to track?

});
it('returns ssoData object with lastUsedConnection and idtokenpayload.name when there is no idtokenpayload.email', function(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idtokenpayload -> idTokenPayload

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

});
it('returns ssoData object with lastUsedConnection and idtokenpayload.email by default', function(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idtokenpayload -> idTokenPayload

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

lastUsedClientID: '...',
sessionClients: ['...'],
sso: true
context('when inside of the hosted login page', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is a different context, please separate it with 1 or 2 new lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

afterEach(function() {
windowHelper.getWindow.restore();
});
it('calls webauth._universalLogin.getSSOData with same params', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain me this test case. Why is it handling the same parameters to the other class's method and why is it accepting strings when it should be a boolean and a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the ULP, we need to run the exact same code we were using in v8, so I'm just calling the old getSSOData (now inside the HostedPages class) with the same params. I don't really care what are the params now, just want to test that I'm just relaying the params correctly

request.get.restore();
});

it('should call ssodata with all the options', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssodata -> ssoData

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to /user/ssodata

done();
});
});
it('should call ssodata with all the ad options', function(done) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ssodata -> ssoData. Also I'd call it: "should call ssoData with all the options including activeDirectories/ad"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made AD uppercase

cb: function(cb) {
cb(null, {
body: {
sso: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add one more parameter to this body? Same for the test below. Why? It makes some noise to me that the sso: false is also passed on many of the tests above of this PR, and I want to fully understand what this getSSOData call ends doing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sso:false is simulating the server response.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then why is it called "with all the options" if you're just passing 1? The previous tests I mentioned have more parameters. Is this correct with a single one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah.. I just copied/pasted from v8. I renamed the test

@luisrudge
Copy link
Contributor Author

I see you're still refering to HLP instead of ULP in the code. Should this be changed? (var names, test descriptions, etc)

I agree with this, but I'll do it in a different PR (replace everything related to HLP to ULP)

Copy link
Contributor

@lbalmaceda lbalmaceda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@luisrudge luisrudge merged commit 3d7ab72 into master Apr 6, 2018
@luisrudge luisrudge added this to the v9.5.0 milestone Apr 24, 2018
@luisrudge luisrudge deleted the fix-ssodata-hlp branch April 24, 2018 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants