Merge Boundary UI OSS branch 'main' at commit 2c72f85d

This commit is contained in:
github-team-secure-boundary committed 2023-01-09 19:33:12 +00:00
commit b5e802ee6c
5 files changed
+41 -19

No files matched your search

@@ -44,19 +44,7 @@
</row.headerCell>
<row.cell>{{principal.id}}</row.cell>
<row.cell>
<Hds::Badge
@icon={{if
(eq principal.constructor.modelName 'group')
'folder-users'
'user'
}}
@text={{t
(concat
'resources.role.principal.types.'
principal.constructor.modelName
)
}}
/>
<PrincipalTypeBadge @model={{principal}} />
</row.cell>
<row.cell>
<ScopeBadge @scope={{principal.scopeModel}} />
@@ -24,14 +24,15 @@ export default class FormRoleAddPrincipalsIndexComponent extends Component {
/**
* Principals not currently assigned to a role.
* @type {[UserModel, GroupModel]}
* @type {[UserModel, GroupModel, ManagedGroupModel]}
*/
@computed('args.{model,model.principals.[],users,groups}')
@computed('args.{model,model.principals.[],users,groups,managedGroups}')
get filteredPrincipals() {
// Retrieve principal IDs assigned to current role
const currentPrincipalIDs = this.args.model.principals.map(
(principal) => principal.principal_id
);
// Retrieve principal IDs not assigned to current role
const unassignedUsers = this.args.users.filter(
({ id }) => !currentPrincipalIDs.includes(id)
@@ -39,7 +40,15 @@ export default class FormRoleAddPrincipalsIndexComponent extends Component {
const unassignedGroups = this.args.groups.filter(
({ id }) => !currentPrincipalIDs.includes(id)
);
return [...unassignedUsers, ...unassignedGroups];
const unassignedManagedGroups = this.args.managedGroups.filter(
({ id }) => !currentPrincipalIDs.includes(id)
);
return [
...unassignedUsers,
...unassignedGroups,
...unassignedManagedGroups,
];
}
// =actions
@@ -16,7 +16,7 @@ export default class LinkToPrincipalComponent extends Component {
return this.args.model.constructor.modelName === 'managed-group';
}
/**
/**
* return route based on principal type
* @type {string}
*/
@@ -1,7 +1,7 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import { hash } from 'rsvp';
import { hash, all } from 'rsvp';
import { loading } from 'ember-loading';
import { notifySuccess, notifyError } from 'core/decorators/notify';
import { resourceFilter } from 'core/decorators/resource-filter';
@@ -38,7 +38,7 @@ export default class ScopesScopeRolesRoleAddPrincipalsRoute extends Route {
* Returns the current role, all users, and all groups
* @return {{role: RoleModel, users: [UserModel], groups: [GroupModel]}}
*/
model() {
async model() {
const role = this.modelFor('scopes.scope.roles.role');
const scopes = this.store.peekAll('scope').toArray();
const scopeIDs = this.scope?.map((scope) => scope.id);
@@ -66,11 +66,35 @@ export default class ScopesScopeRolesRoleAddPrincipalsRoute extends Route {
}
)
: this.store.query('group', { scope_id: 'global', recursive: true });
//query authmethods from all the scopes
const oidcAuthMethods = scopeIDs?.length
? await this.resourceFilterStore.queryBy(
'auth-method',
{ scope_id: scopeIDs, type: 'oidc' },
{ scope_id: 'global', recursive: true }
)
: await this.resourceFilterStore.queryBy(
'auth-method',
{ type: 'oidc' },
{ scope_id: 'global', recursive: true }
);
//extract oidc authMethod IDs
const oidcAuthMethodIDs = oidcAuthMethods.map(({ id }) => id);
//query all the managed groups for each auth method id
const managedGroups = await all(
oidcAuthMethodIDs.map((auth_method_id) =>
this.store.query('managed-group', { auth_method_id })
)
);
const managedGroupModels = managedGroups
.map((models) => models.map((model) => model))
.flat();
return hash({
role,
scopes,
users,
groups,
managedGroups: managedGroupModels,
});
}
@@ -78,6 +78,7 @@
@model={{@model.role}}
@users={{@model.users}}
@groups={{@model.groups}}
@managedGroups={{@model.managedGroups}}
@submit={{route-action 'addPrincipals' @model.role}}
@cancel={{route-action 'cancel'}}
/>