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

Don't send ion access token to non-ion servers #7839

Merged
merged 3 commits into from
May 15, 2019
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
5 changes: 4 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
Change Log
==========
### 1.58 - 2019-06-01
### 1.58 - 2019-06-03

##### Additions :tada:
* Added support for new `BingMapsStyle` values `ROAD_ON_DEMAND` and `AERIAL_WITH_LABELS_ON_DEMAND`. The older versions of these, `ROAD` and `AERIAL_WITH_LABELS`, have been deprecated by Bing. [#7808](https://github.com/AnalyticalGraphicsInc/cesium/pull/7808)
* Added syntax to delete data from existing properties via CZML. [#7818](https://github.com/AnalyticalGraphicsInc/cesium/pull/7818)
* `BingMapsImageryProvider` now uses `DiscardEmptyTileImagePolicy` by default to detect missing tiles as zero-length responses instead of inspecting pixel values. [#7810](https://github.com/AnalyticalGraphicsInc/cesium/pull/7810)

##### Fixes :wrench:
* Fixed an edge case where Cesium would provide ion access token credentials to non-ion servers if the actual asset entrypoint was being hosted by ion. [#7839](https://github.com/AnalyticalGraphicsInc/cesium/pull/7839)

### 1.57 - 2019-05-01

##### Additions :tada:
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/IonResource.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
define([
'../ThirdParty/Uri',
'../ThirdParty/when',
'./Check',
'./Credit',
Expand All @@ -9,6 +10,7 @@ define([
'./Resource',
'./RuntimeError'
], function(
Uri,
when,
Check,
Credit,
Expand Down Expand Up @@ -64,6 +66,7 @@ define([

// The asset endpoint data returned from ion.
this._ionEndpoint = endpoint;
this._ionEndpointDomain = isExternal ? undefined : new Uri(endpoint.url).authority;

// The endpoint resource to fetch when a new token is needed
this._ionEndpointResource = endpointResource;
Expand Down Expand Up @@ -180,7 +183,8 @@ define([
};

IonResource.prototype._makeRequest = function(options) {
if (this._isExternal) {
// Don't send ion access token to non-ion servers.
if (this._isExternal || new Uri(this.url).authority !== this._ionEndpointDomain) {
return Resource.prototype._makeRequest.call(this, options);
}

Expand Down
12 changes: 12 additions & 0 deletions Specs/Core/IonResourceSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ defineSuite([
expect(_makeRequest.calls.argsFor(0)[0]).toBe(options);
});

it('Calls base _makeRequest with no changes for ion assets with external urls', function() {
var originalOptions = {};
var expectedOptions = {};

var _makeRequest = spyOn(Resource.prototype, '_makeRequest');
var endpointResource = IonResource._createEndpointResource(assetId);
var resource = new IonResource(endpoint, endpointResource);
resource.url = 'http://test.invalid';
resource._makeRequest(originalOptions);
expect(_makeRequest).toHaveBeenCalledWith(expectedOptions);
});

it('Calls base fetchImage with preferBlob for ion assets', function() {
var fetchImage = spyOn(Resource.prototype, 'fetchImage');
var endpointResource = IonResource._createEndpointResource(assetId);
Expand Down