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

205 Access Control Changes #444

Merged
merged 1 commit into from
Jul 8, 2016
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
9 changes: 2 additions & 7 deletions src/app/model/account/account.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,7 @@
if (this.adminOverride) {
return false;
}
var ADMIN_SCOPES = [
'cloud_controller.admin',
'ucp.admin'
];
return angular.isDefined(this.data.scope) &&
_.intersection(this.data.scope, ADMIN_SCOPES).length > 0;
return this.data.isAdmin;
},

/**
Expand All @@ -144,7 +139,7 @@
var loginRes = response.data;
this.data = {
username: loginRes.account,
scope: loginRes.scope ? loginRes.scope.split(' ') : []
isAdmin: loginRes.admin
};
},

Expand Down
6 changes: 3 additions & 3 deletions src/plugins/cloud-foundry/model/auth/checkers/base-access.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
function BaseAccess(principal) {
return {
create: function () {
return principal.isAdmin();
return principal.isAdmin;
},

update: function () {
return principal.isAdmin();
return principal.isAdmin;
},

delete: function () {
return principal.isAdmin();
return principal.isAdmin;
},

_doesContainGuid: function (array, guid) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
/**
* @name create
* @description Does user have create organization permission in the space
* @param {Object} space - Domain space
* @returns {boolean}
*/
create: function (space) {
return this.principal.isAdmin(space);
create: function () {
// Formerly, this had a param: @param {Object} space - Domain space
// Not sure if we need that or not.
return this.principal.isAdmin;
},

/**
Expand All @@ -58,7 +59,7 @@
* @returns {boolean}
*/
delete: function () {
return this.principal.isAdmin();
return this.principal.isAdmin;
},

/**
Expand Down
6 changes: 2 additions & 4 deletions src/plugins/cloud-foundry/model/auth/principal.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@

var Principal = modelManager.retrieve('cloud-foundry.model.auth.principal');
return new Principal(authInfo.username,
authInfo.access_token || authInfo.authToken,
authInfo.refresh_token || authInfo.refreshToken,
authInfo.expires_in || authInfo.expiresIn,
authInfo.token_type || authInfo.tokenType,
authInfo.scope, authInfo.userInfo);
authInfo.isAdmin,
authInfo.userInfo);
}
};
}
Expand Down
24 changes: 6 additions & 18 deletions src/plugins/cloud-foundry/model/auth/principal.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,18 @@
* @name Principal
* @description initialise a Principal object
* @param {String} username - username
* @param {String} authToken - OAuth access token
* @param {String} refreshToken - OAuth refresh token
* @param {String} expiresIn - expires in
* @param {String} tokenType - token type
* @param {Object} scope - scope
* @param {Boolean} isAdmin - is this user and admin
* @param {Object} userInfo - user info
* @constructor
*/
function Principal(username, authToken, refreshToken, expiresIn, tokenType, scope, userInfo) {
function Principal(username, expiresIn, isAdmin, userInfo) {
this.username = username;
this.authToken = authToken;
this.refreshToken = refreshToken;
// this.authToken = authToken;
// this.refreshToken = refreshToken;
this.expiresIn = expiresIn;
this.tokenType = tokenType;
this.scope = scope;
// this.tokenType = tokenType;
this.isAdmin = isAdmin;
this.userInfo = userInfo;
}

Expand All @@ -63,15 +60,6 @@
return this.isAdmin() || flags[operation];
},

/**
* @name isAdmin
* @description Is user an admin
* @returns {boolean}
*/
isAdmin: function () {
return _.includes(this.scope, 'cloud_controller.admin');
},

/**
* @name isAllowed
* @description Is user permitted to do the action
Expand Down