Skip to content

Commit

Permalink
fix auth mismatching where the user appears to have access to more gr…
Browse files Browse the repository at this point in the history
…oups than they really have access
  • Loading branch information
Colin Bendell committed Feb 14, 2017
1 parent b0c6774 commit 4f4a332
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea
node_modules
hostlist.json
13 changes: 11 additions & 2 deletions src/website.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class WebSite {
* @param auth {Object} providing the `path`, and `section` for the authentication. Alternatively, you can pass in
* `clientToken`, `clientSecret`, `accessToken`, and `host` directly.
*/
constructor(auth = {path: "~/.edgerc", section: "papi"}) {
constructor(auth = {path: "~/.edgerc", section: "default"}) {

if (auth.clientToken && auth.clientSecret && auth.accessToken && auth.host)
this._edge = new EdgeGrid(auth.clientToken.auth.clientSecret, auth.accessToken, auth.host, auth.debug);
Expand Down Expand Up @@ -93,7 +93,7 @@ class WebSite {
})
})
.then(data => {
this._propertyHostnameList = data.propertyHostnameList;
this._propertyHostnameList = data.propertyHostnameList || {};
this._accountId = data.accountId;
if (data.groups && data.groups.items)
data.groups.items.map(item => {
Expand All @@ -116,6 +116,7 @@ class WebSite {
let promiseList = [];

propList.map(v => {
if (!v || !v.properties || !v.properties.items) return;
return v.properties.items.map(item => {

//TODO: should use toJSON() instead of the primative toString()
Expand All @@ -138,6 +139,10 @@ class WebSite {
})
.then(hostListList => {
hostListList.map(hostList => {
if (!hostList || !hostList.propertyId || !hostList.propertyVersion) {
console.log("ignoring: ", hostList);
return;
}
let prop = this._propertyById[hostList.propertyId];
let version = hostList.propertyVersion;
if (!this._propertyHostnameList[hostList.propertyId]) {
Expand Down Expand Up @@ -265,6 +270,10 @@ class WebSite {
let parsed = JSON.parse(response.body);
resolve(parsed);
}
else if (response.statusCode == 403) {
console.info('... ignoring {%s : %s}', contractId, groupId);
resolve(null);
}
else {
reject(response);
}
Expand Down

0 comments on commit 4f4a332

Please sign in to comment.