Icu 12707 update role mirage (#2319)
* feat: 🎸 add grant_scope_ids to role mirage ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12707 * feat: 🎸 set grant_scope_ids in onboarding workflow ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12707 * refactor: 💡 set grant_scope_ids when calling updateGrantScopeID ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12707 * refactor: 💡 add TODO for removal of grant_scope_id ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-12707
This commit is contained in:
1 parent
f9e85aa9aa
commit
c6a917d21b
5 files changed
+20
-12
No files matched your search
@@ -320,6 +320,13 @@ function routes() {
|
||||
const role = roles.find(id);
|
||||
let updatedAttrs = {};
|
||||
|
||||
if (method === 'set-grant-scopes') {
|
||||
updatedAttrs = {
|
||||
version: attrs.version,
|
||||
grantScopeIds: attrs.grantScopeIds,
|
||||
};
|
||||
}
|
||||
|
||||
// Principals is a combined list of users, groups and managed groups, but in Mirage we've
|
||||
// internally modelled them as separate lists. Therefore we must check
|
||||
// the type by looking up the user or group first, then determine which
|
||||
|
||||
@@ -26,6 +26,9 @@ export default factory.extend({
|
||||
],
|
||||
|
||||
id: () => generateId('r_'),
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
grant_scope_id: 'this',
|
||||
grant_scope_ids: () => ['this'],
|
||||
|
||||
/**
|
||||
* Adds principals to the role.
|
||||
@@ -42,14 +45,4 @@ export default factory.extend({
|
||||
role.update({ users, groups, managedGroups });
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Set the grant scope ID to match the scope ID.
|
||||
*/
|
||||
afterCreate(role) {
|
||||
const {
|
||||
scope: { id },
|
||||
} = role;
|
||||
role.update({ grant_scope_id: id });
|
||||
},
|
||||
});
|
||||
@@ -38,8 +38,12 @@ export default ApplicationSerializer.extend({
|
||||
|
||||
if (!json.principals.length) delete json.principals;
|
||||
|
||||
// default grant scope
|
||||
if (!json.grant_scope_id) json.grant_scope_id = json.scope.id;
|
||||
// default grant scopes
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
if (!json.grant_scope_id) json.grant_scope_id = 'this';
|
||||
if (json.grant_scope_ids.length === 0) {
|
||||
json.grant_scope_ids = ['this'];
|
||||
}
|
||||
|
||||
return json;
|
||||
},
|
||||
|
||||
@@ -11,6 +11,8 @@ export default class FormRoleGrantsComponent extends Component {
|
||||
|
||||
@action
|
||||
updateGrantScopeID(id) {
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
this.args.model.grant_scope_id = id;
|
||||
this.args.model.grant_scope_ids = [id];
|
||||
}
|
||||
}
|
||||
@@ -132,7 +132,9 @@ export default class OnboardingRoute extends Route {
|
||||
|
||||
async createGrants(org, project, target, role) {
|
||||
role.scopeID = org.id;
|
||||
// TODO: all grant_scope_id instances will be removed in future PR
|
||||
role.grant_scope_id = project.id;
|
||||
role.grant_scope_ids = [project.id];
|
||||
try {
|
||||
await role.save();
|
||||
await role.saveGrantStrings([
|
||||
|
||||
Reference in new issue
Block a user