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

fixed authority issue #452

Merged
merged 2 commits into from
Oct 22, 2018
Merged

fixed authority issue #452

merged 2 commits into from
Oct 22, 2018

Conversation

rohitnarula7176
Copy link
Contributor

@rohitnarula7176 rohitnarula7176 commented Oct 8, 2018

#347
*Fixed issue regarding saving authorities tied to AT.
*Added storeAuthStateInCookie check for authority for IE/Edge fix.
*Other minor fixes.
*Removed doc script from package.json just for the time being. Travis build is failing with the doc script. Need to re-add it.

@@ -92,9 +92,9 @@
"clean": "shx rm -rf dist docs",
"doc": "typedoc --out ./docs ./src/**/* --gitRevision dev",
"build:modules": "tsc && tsc -m es6 --outDir lib-es6",
"build": "npm run clean && npm run doc && npm run build:modules && webpack",
"build": "npm run clean && npm run build:modules && webpack",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we removing the docs here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Please see my comment summary on the PR above. I removed the docs temporarily as the doc script was failing on travis.

Copy link
Contributor

@nehaagrawal nehaagrawal Oct 11, 2018

Choose a reason for hiding this comment

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

It used to work. Do you know what is the issue. May be we should fix the issue instead of removing it. Also why we are making changes in msal-angular as part of this PR? This PR is only to fix the authority issue in msal-core.

return url;
var urlObject = this.GetUrlComponents(url);
var pathArray = urlObject.PathSegments;
if (pathArray.length !== 0 && pathArray[0] === "common" || pathArray[0] === "organizations") {
Copy link
Contributor

Choose a reason for hiding this comment

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

please use constants for common and organizations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This existed previously and constants need to be applied at many places in the code base still. I will leave that up to you and Prithvi to take when you guys have time.

} else {
this._logger.warning("ClientInfo not received in the response from AAD");
user = User.createUser(idToken, new ClientInfo(clientInfo), authority);
user = User.createUser(idToken, new ClientInfo(clientInfo),);
Copy link
Contributor

Choose a reason for hiding this comment

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

extra comma? may be a typo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -80,7 +80,7 @@
"clean": "shx rm -rf dist docs lib-commonjs lib-es6",
"doc": "typedoc --out ./docs ./src/**/* --gitRevision dev",
"build:modules": "tsc && tsc -m es6 --outDir lib-es6",
"build": "npm run clean && npm run doc && npm run build:modules && webpack && grunt && npm test",
"build": "npm run clean && npm run build:modules && webpack && grunt && npm test",
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we removing the docs here?

@@ -1784,7 +1758,10 @@ protected getCachedTokenInternal(scopes : Array<string> , user: User): CacheResu
this._cacheStorage.setItem(Constants.renewStatus + tokenResponse.stateResponse, Constants.tokenRenewStatusCompleted);
this._cacheStorage.removeAcquireTokenEntries(authorityKey, acquireTokenUserKey);
//this is required if navigateToLoginRequestUrl=false
this._cacheStorage.clearCookie();
if (this.storeAuthStateInCookie) {
this._cacheStorage.setItemCookie(authorityKey, '', -1);
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we not doing this 'this._cacheStorage.setItemCookie(authorityKey, '', -1);' inside clearcookie?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because authority key is dynamically created with state unlike state, nonce and loginStartPage. In order to set it inside the clearCookie function, you will have to change the clearCookie api to accept a optional string.

this._cacheStorage.setItem(authorityKey, this.authority);
}

this._cacheStorage.setItem(authorityKey, this.authority, this.storeAuthStateInCookie);
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we storing authority key in cookie? In the original design of IE/Edge fix, we were storing only state and nonce. Does authority key get wiped out during changing security zone?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The entire storage can get wiped out during the transition between zones. Since the tokens are tied to authority, we need a way to restore the authority from cookie as well otherwise all the tokens will be saved with authority set to undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

we never saw this issue when we released IE/Edge fix. I am curious why we didn't notice it. We can discuss this offline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue existed in the IE/Edge fix release but was not caught during testing. We can easily reproduce this. We can discuss this during our meeting tom.

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 some test cases?

this._cacheStorage.setItem(authorityKey, this.authority);
}

this._cacheStorage.setItem(authorityKey, this.authority);
Copy link
Contributor

@nehaagrawal nehaagrawal Oct 11, 2018

Choose a reason for hiding this comment

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

are we missing the storeAuthStateInCookie flag here? You are passing it on line 412.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, we only need this flag for redirect functions like loginRedirect and acquireTokenRedirect.

Copy link
Contributor

@nehaagrawal nehaagrawal Oct 12, 2018

Choose a reason for hiding this comment

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

We saw some issues earlier when storeAuthStateInCookie flag was added to only loginRedirect and acquireTokenRedirect. We are currently passing this flag for popup cases as well. I think we should do it everywhere for consistency.

this._cacheStorage.setItem(Constants.loginRequest, window.location.href, this.storeAuthStateInCookie);

if (Utils.isEmpty(this._cacheStorage.getItem(authorityKey))) {
this._cacheStorage.setItem(authorityKey, acquireTokenAuthority.CanonicalAuthority);
}
this._cacheStorage.setItem(authorityKey, acquireTokenAuthority.CanonicalAuthority);
Copy link
Contributor

Choose a reason for hiding this comment

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

are we missing the storeAuthStateInCookie flag here? You are passing it on line 412.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as above.

this._cacheStorage.setItem(authorityKey, authenticationRequest.authority);
}

this._cacheStorage.setItem(authorityKey, authenticationRequest.authority);
Copy link
Contributor

Choose a reason for hiding this comment

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

are we missing the storeAuthStateInCookie flag here? You are passing it on line 412.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same comment as above.

@@ -36,7 +36,7 @@
"@angular/platform-browser-dynamic": "~4.3.0",
"@angular/router": "^4.3.0",
"@types/handlebars": "4.0.33",
"@types/jasmine": "^2.8.6",
"@types/jasmine": "2.5.38",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should upgrade to @types/jasmine": "2.5.41",instead of 2.5.38 as per this github issue DefinitelyTyped/DefinitelyTyped#14569. I have created a separate PR to fix this issue. Please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The same link has the version 2.5.38 listed as well which worked for other users. I don't think it matters which version to use as long as the doc issue is fixed. If you want , you can change the version later on after merging this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

If a higher version fixes the issue we shouldn't downgrade too much. I have fixed it in a different PR and merge changes to this PR.

@@ -29,7 +29,7 @@
},
"devDependencies": {
"@types/handlebars": "4.0.33",
"@types/jasmine": "^2.6.0",
"@types/jasmine": "2.5.38",
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

@rohitnarula7176 rohitnarula7176 merged commit f65cb13 into dev Oct 22, 2018
@rohitnarula7176 rohitnarula7176 deleted the ronaru/Issue_347 branch October 22, 2018 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants