Skip to content

Commit d61f670

Browse files
[backend] Change organizations visibility to take care of inferences (#9078)
Co-authored-by: Julien Richard <julien.richard@filigran.io>
1 parent 7d9066b commit d61f670

File tree

13 files changed

+84
-54
lines changed

13 files changed

+84
-54
lines changed

opencti-platform/opencti-front/src/private/components/settings/users/edition/UserEditionOverview.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import SelectField from '../../../../../components/fields/SelectField';
1515
import { SubscriptionFocus } from '../../../../../components/Subscription';
1616
import MarkdownField from '../../../../../components/fields/MarkdownField';
1717
import ObjectOrganizationField from '../../../common/form/ObjectOrganizationField';
18-
import { convertOrganizations } from '../../../../../utils/edition';
1918
import { useFormatter } from '../../../../../components/i18n';
2019
import DateTimePickerField from '../../../../../components/DateTimePickerField';
2120
import { fieldSpacingContainerStyle } from '../../../../../utils/field';
@@ -105,7 +104,6 @@ UserEditionOverviewComponentProps
105104
const { t_i18n } = useFormatter();
106105
const { me, settings } = useAuth();
107106
const theme = useTheme<Theme>();
108-
109107
const [commitFocus] = useApiMutation(userEditionOverviewFocus);
110108
const [commitFieldPatch] = useApiMutation(userMutationFieldPatch);
111109
const [commitOrganizationAdd] = useApiMutation(userMutationOrganizationAdd);
@@ -114,8 +112,10 @@ UserEditionOverviewComponentProps
114112

115113
const userIsOnlyOrganizationAdmin = isOnlyOrganizationAdmin();
116114
const external = user.external === true;
117-
const objectOrganization = convertOrganizations(user);
118-
115+
const objectOrganization = (user.objectAssignedOrganization?.edges ?? []).map((n) => ({
116+
label: n.node.name,
117+
value: n.node.id,
118+
}));
119119
const initialValues = {
120120
name: user.name,
121121
user_email: user.user_email,
@@ -159,7 +159,7 @@ UserEditionOverviewComponentProps
159159
name: string,
160160
values: { label: string; value: string }[],
161161
) => {
162-
const currentValues = (user?.objectOrganization?.edges ?? []).map((n) => ({
162+
const currentValues = (user?.objectAssignedOrganization?.edges ?? []).map((n) => ({
163163
label: n.node.name,
164164
value: n.node.id,
165165
}));
@@ -389,7 +389,7 @@ const UserEditionOverview = createFragmentContainer(
389389
id
390390
name
391391
}
392-
objectOrganization(orderBy: $organizationsOrderBy, orderMode: $organizationsOrderMode) {
392+
objectAssignedOrganization(orderBy: $organizationsOrderBy, orderMode: $organizationsOrderMode) {
393393
edges {
394394
node {
395395
id

opencti-platform/opencti-front/src/schema/relay.schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,7 @@ type User implements BasicObject & InternalObject {
16541654
restrict_delete: Boolean
16551655
groups(orderBy: GroupsOrdering, orderMode: OrderingMode): GroupConnection
16561656
objectOrganization(orderBy: OrganizationsOrdering, orderMode: OrderingMode): OrganizationConnection
1657+
objectAssignedOrganization(orderBy: OrganizationsOrdering, orderMode: OrderingMode): OrganizationConnection
16571658
created_at: DateTime!
16581659
updated_at: DateTime!
16591660
sessions: [SessionDetail]

opencti-platform/opencti-graphql/config/schema/opencti.graphql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,6 +1574,10 @@ type User implements BasicObject & InternalObject {
15741574
orderBy: OrganizationsOrdering
15751575
orderMode: OrderingMode
15761576
): OrganizationConnection @auth(for: [SETTINGS_SETACCESSES, VIRTUAL_ORGANIZATION_ADMIN])
1577+
objectAssignedOrganization(
1578+
orderBy: OrganizationsOrdering
1579+
orderMode: OrderingMode
1580+
): OrganizationConnection @auth(for: [SETTINGS_SETACCESSES, VIRTUAL_ORGANIZATION_ADMIN])
15771581
created_at: DateTime!
15781582
updated_at: DateTime!
15791583
sessions: [SessionDetail] @auth(for: [SETTINGS_SETACCESSES, VIRTUAL_ORGANIZATION_ADMIN])

opencti-platform/opencti-graphql/src/database/engine.js

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ import {
2626
offsetToCursor,
2727
pascalize,
2828
READ_DATA_INDICES,
29+
READ_DATA_INDICES_WITHOUT_INFERRED,
2930
READ_DATA_INDICES_WITHOUT_INTERNAL_WITHOUT_INFERRED,
3031
READ_ENTITIES_INDICES,
32+
READ_ENTITIES_INDICES_WITHOUT_INFERRED,
3133
READ_INDEX_INFERRED_ENTITIES,
3234
READ_INDEX_INFERRED_RELATIONSHIPS,
3335
READ_INDEX_INTERNAL_OBJECTS,
@@ -41,6 +43,7 @@ import {
4143
READ_INDEX_STIX_SIGHTING_RELATIONSHIPS,
4244
READ_PLATFORM_INDICES,
4345
READ_RELATIONSHIPS_INDICES,
46+
READ_RELATIONSHIPS_INDICES_WITHOUT_INFERRED,
4447
UPDATE_OPERATION_ADD,
4548
waitInSec,
4649
WRITE_PLATFORM_INDICES
@@ -501,7 +504,7 @@ export const buildDataRestrictions = async (context, user, opts = {}) => {
501504
// Data with Empty granted_refs are not visible
502505
// Data with granted_refs users that participate to at least one
503506
const should = [excludedEntityMatches];
504-
const shouldOrgs = user.allowed_organizations
507+
const shouldOrgs = user.organizations
505508
.map((m) => ({ match: { [buildRefRelationSearchKey(RELATION_GRANTED_TO)]: m.internal_id } }));
506509
should.push(...shouldOrgs);
507510
// User individual or data created by this individual must be accessible
@@ -1474,50 +1477,72 @@ export const elConvertHits = async (data, opts = {}) => {
14741477
return convertedHits;
14751478
};
14761479

1477-
export const computeQueryIndices = (indices, typeOrTypes) => {
1480+
const withInferencesEntities = (indices, withInferences) => {
1481+
return withInferences ? [READ_INDEX_INFERRED_ENTITIES, ...indices] : indices;
1482+
};
1483+
const withInferencesRels = (indices, withInferences) => {
1484+
return withInferences ? [READ_INDEX_INFERRED_RELATIONSHIPS, ...indices] : indices;
1485+
};
1486+
export const computeQueryIndices = (indices, typeOrTypes, withInferences = true) => {
14781487
const types = (Array.isArray(typeOrTypes) || isEmptyField(typeOrTypes)) ? typeOrTypes : [typeOrTypes];
14791488
// If indices are explicitly defined, just rely on the definition
14801489
if (isEmptyField(indices)) {
14811490
// If not and have no clue about the expected types, ask for all indices.
14821491
// Worst case scenario that need to be avoided.
14831492
if (isEmptyField(types)) {
1484-
return READ_DATA_INDICES;
1493+
return withInferences ? READ_DATA_INDICES : READ_DATA_INDICES_WITHOUT_INFERRED;
14851494
}
14861495
// If types are defined we need to infer from them the correct indices
14871496
return R.uniq(types.map((findType) => {
14881497
// If defined types are abstract, try to restrict the indices as much as possible
14891498
if (isAbstract(findType)) {
14901499
// For objects
14911500
if (isBasicObject(findType)) {
1492-
if (isInternalObject(findType)) return [READ_INDEX_INFERRED_ENTITIES, READ_INDEX_INTERNAL_OBJECTS];
1493-
if (isStixMetaObject(findType)) return [READ_INDEX_INFERRED_ENTITIES, READ_INDEX_STIX_META_OBJECTS];
1494-
if (isStixDomainObject(findType)) return [READ_INDEX_INFERRED_ENTITIES, READ_INDEX_STIX_DOMAIN_OBJECTS];
1495-
if (isStixCoreObject(findType)) return [READ_INDEX_INFERRED_ENTITIES, READ_INDEX_STIX_DOMAIN_OBJECTS, READ_INDEX_STIX_CYBER_OBSERVABLES];
1496-
if (isStixObject(findType)) return [READ_INDEX_INFERRED_ENTITIES, READ_INDEX_STIX_META_OBJECTS, READ_INDEX_STIX_DOMAIN_OBJECTS, READ_INDEX_STIX_CYBER_OBSERVABLES];
1497-
return READ_ENTITIES_INDICES;
1501+
if (isInternalObject(findType)) {
1502+
return withInferencesEntities([READ_INDEX_INTERNAL_OBJECTS], withInferences);
1503+
}
1504+
if (isStixMetaObject(findType)) {
1505+
return withInferencesEntities([READ_INDEX_STIX_META_OBJECTS], withInferences);
1506+
}
1507+
if (isStixDomainObject(findType)) {
1508+
return withInferencesEntities([READ_INDEX_STIX_DOMAIN_OBJECTS], withInferences);
1509+
}
1510+
if (isStixCoreObject(findType)) {
1511+
return withInferencesEntities([READ_INDEX_STIX_DOMAIN_OBJECTS, READ_INDEX_STIX_CYBER_OBSERVABLES], withInferences);
1512+
}
1513+
if (isStixObject(findType)) {
1514+
return withInferencesEntities([READ_INDEX_STIX_META_OBJECTS, READ_INDEX_STIX_DOMAIN_OBJECTS, READ_INDEX_STIX_CYBER_OBSERVABLES], withInferences);
1515+
}
1516+
return withInferences ? READ_ENTITIES_INDICES : READ_ENTITIES_INDICES_WITHOUT_INFERRED;
14981517
}
14991518
// For relationships
15001519
if (isBasicRelationship(findType) || STIX_REF_RELATIONSHIP_TYPES.includes(findType)) {
1501-
if (isInternalRelationship(findType)) return [READ_INDEX_INFERRED_RELATIONSHIPS, READ_INDEX_INTERNAL_RELATIONSHIPS];
1502-
if (isStixSightingRelationship(findType)) return [READ_INDEX_INFERRED_RELATIONSHIPS, READ_INDEX_STIX_SIGHTING_RELATIONSHIPS];
1503-
if (isStixCoreRelationship(findType)) return [READ_INDEX_INFERRED_RELATIONSHIPS, READ_INDEX_STIX_CORE_RELATIONSHIPS];
1520+
if (isInternalRelationship(findType)) {
1521+
return withInferencesRels([READ_INDEX_INTERNAL_RELATIONSHIPS], withInferences);
1522+
}
1523+
if (isStixSightingRelationship(findType)) {
1524+
return withInferencesRels([READ_INDEX_STIX_SIGHTING_RELATIONSHIPS], withInferences);
1525+
}
1526+
if (isStixCoreRelationship(findType)) {
1527+
return withInferencesRels([READ_INDEX_STIX_CORE_RELATIONSHIPS], withInferences);
1528+
}
15041529
if (isStixRefRelationship(findType) || STIX_REF_RELATIONSHIP_TYPES.includes(findType)) {
1505-
return [READ_INDEX_INFERRED_RELATIONSHIPS, READ_INDEX_STIX_META_RELATIONSHIPS, READ_INDEX_STIX_CYBER_OBSERVABLE_RELATIONSHIPS];
1530+
return withInferencesRels([READ_INDEX_STIX_META_RELATIONSHIPS, READ_INDEX_STIX_CYBER_OBSERVABLE_RELATIONSHIPS], withInferences);
15061531
}
15071532
if (isStixRelationship(findType)) {
1508-
return [READ_INDEX_INFERRED_RELATIONSHIPS, READ_INDEX_STIX_CORE_RELATIONSHIPS, READ_INDEX_STIX_SIGHTING_RELATIONSHIPS, READ_INDEX_STIX_META_RELATIONSHIPS,
1509-
READ_INDEX_STIX_CYBER_OBSERVABLE_RELATIONSHIPS];
1533+
return withInferencesRels([READ_INDEX_STIX_CORE_RELATIONSHIPS, READ_INDEX_STIX_SIGHTING_RELATIONSHIPS, READ_INDEX_STIX_META_RELATIONSHIPS,
1534+
READ_INDEX_STIX_CYBER_OBSERVABLE_RELATIONSHIPS], withInferences);
15101535
}
1511-
return READ_RELATIONSHIPS_INDICES;
1536+
return withInferences ? READ_RELATIONSHIPS_INDICES : READ_RELATIONSHIPS_INDICES_WITHOUT_INFERRED;
15121537
}
15131538
// Fallback
15141539
throw UnsupportedError('Fail to compute indices for unknown type', { type: findType });
15151540
}
15161541
// If concrete type, infer the index from the type
15171542
if (isBasicObject(findType)) {
1518-
return [READ_INDEX_INFERRED_ENTITIES, `${inferIndexFromConceptType(findType)}*`];
1543+
return withInferencesEntities([`${inferIndexFromConceptType(findType)}*`], withInferences);
15191544
}
1520-
return [READ_INDEX_INFERRED_RELATIONSHIPS, `${inferIndexFromConceptType(findType)}*`];
1545+
return withInferencesRels([`${inferIndexFromConceptType(findType)}*`], withInferences);
15211546
}).flat());
15221547
}
15231548
return indices;

opencti-platform/opencti-graphql/src/database/middleware-loader.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export interface EntityOptions<T extends BasicStoreCommon> extends EntityFilters
9494
ids?: Array<string>
9595
indices?: Array<string>
9696
includeAuthorities?: boolean | null
97+
withInferences?: boolean
9798
includeDeletedInDraft?: boolean | null
9899
}
99100

@@ -313,7 +314,7 @@ export const listRelationsPaginated = async <T extends BasicStoreRelation>(conte
313314
export const listAllRelations = async <T extends StoreProxyRelation>(context: AuthContext, user: AuthUser, type: string | Array<string>,
314315
args: RelationOptions<T> = {}): Promise<Array<T>> => {
315316
const { indices } = args;
316-
const computedIndices = computeQueryIndices(indices, type);
317+
const computedIndices = computeQueryIndices(indices, type, args.withInferences);
317318
const paginateArgs = buildRelationsFilter(type, args);
318319
return elList(context, user, computedIndices, paginateArgs);
319320
};
@@ -525,7 +526,7 @@ export const listEntitiesThroughRelationsPaginated = async <T extends BasicStore
525526
}],
526527
filterGroups: [],
527528
};
528-
const connectedRelations = await listAllRelations<BasicStoreRelation>(context, user, relationType, { filters, connectionFormat: false });
529+
const connectedRelations = await listAllRelations<BasicStoreRelation>(context, user, relationType, { withInferences: args.withInferences, filters, connectionFormat: false });
529530
if (connectedRelations.length === 0) {
530531
// no connection found (because of relation direction), just return an empty result
531532
return emptyPaginationResult();

opencti-platform/opencti-graphql/src/domain/user.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,11 @@ export const batchCreators = async (context, user, userListIds) => {
234234
return userIds.map((ids) => ids.map((id) => INTERNAL_USERS[id] || buildCreatorUser(platformUsers.get(id)) || SYSTEM_USER));
235235
};
236236

237+
export const userOrganizationsPaginatedWithoutInferences = async (context, user, userId, opts) => {
238+
const args = { ...opts, withInferences: false };
239+
return listEntitiesThroughRelationsPaginated(context, user, userId, RELATION_PARTICIPATE_TO, ENTITY_TYPE_IDENTITY_ORGANIZATION, false, args);
240+
};
241+
237242
export const userOrganizationsPaginated = async (context, user, userId, opts) => {
238243
return listEntitiesThroughRelationsPaginated(context, user, userId, RELATION_PARTICIPATE_TO, ENTITY_TYPE_IDENTITY_ORGANIZATION, false, opts);
239244
};
@@ -1260,7 +1265,6 @@ const buildSessionUser = (origin, impersonate, provider, settings) => {
12601265
default_hidden_types: user.default_hidden_types,
12611266
group_ids: user.groups?.map((g) => g.internal_id) ?? [],
12621267
organizations: user.organizations ?? [],
1263-
allowed_organizations: user.allowed_organizations,
12641268
administrated_organizations: user.administrated_organizations ?? [],
12651269
inside_platform_organization: user.inside_platform_organization,
12661270
allowed_marking: user.allowed_marking.map((m) => ({
@@ -1350,10 +1354,9 @@ export const buildCompleteUser = async (context, client) => {
13501354
);
13511355
const userGroupsPromise = listAllToEntitiesThroughRelations(context, SYSTEM_USER, client.id, RELATION_MEMBER_OF, ENTITY_TYPE_GROUP);
13521356
const settings = await getEntityFromCache(context, SYSTEM_USER, ENTITY_TYPE_SETTINGS);
1353-
const allowed_organizations = await listAllToEntitiesThroughRelations(context, SYSTEM_USER, client.id, RELATION_PARTICIPATE_TO, ENTITY_TYPE_IDENTITY_ORGANIZATION);
1354-
const userOrganizations = allowed_organizations.map((m) => m.internal_id);
1355-
const isUserPlatform = settings.platform_organization ? userOrganizations.includes(settings.platform_organization) : true;
13561357
const [individuals, organizations, groups] = await Promise.all([individualsPromise, organizationsPromise, userGroupsPromise]);
1358+
const userOrganizationIds = organizations.map((m) => m.internal_id);
1359+
const isUserPlatform = settings.platform_organization ? userOrganizationIds.includes(settings.platform_organization) : true;
13571360
const roles = await getRoles(context, groups);
13581361
const capabilities = await getCapabilities(context, client.id, roles);
13591362
const isByPass = R.find((s) => s.name === BYPASS, capabilities) !== undefined;
@@ -1366,7 +1369,7 @@ export const buildCompleteUser = async (context, client) => {
13661369

13671370
// Default hidden types
13681371
const defaultHiddenTypesGroups = getDefaultHiddenTypes(groups);
1369-
const defaultHiddenTypesOrgs = getDefaultHiddenTypes(allowed_organizations);
1372+
const defaultHiddenTypesOrgs = getDefaultHiddenTypes(organizations);
13701373
const default_hidden_types = uniq(defaultHiddenTypesGroups.concat(defaultHiddenTypesOrgs));
13711374

13721375
// effective confidence level
@@ -1386,7 +1389,6 @@ export const buildCompleteUser = async (context, client) => {
13861389
default_hidden_types,
13871390
groups,
13881391
organizations,
1389-
allowed_organizations,
13901392
administrated_organizations,
13911393
individual_id: individualId,
13921394
inside_platform_organization: isUserPlatform,

opencti-platform/opencti-graphql/src/generated/graphql.ts

Lines changed: 13 additions & 5 deletions
Large diffs are not rendered by default.

opencti-platform/opencti-graphql/src/resolvers/user.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
userGroupsPaginated,
5353
userIdDeleteRelation,
5454
userOrganizationsPaginated,
55+
userOrganizationsPaginatedWithoutInferences,
5556
userRenewToken,
5657
userWithOrigin
5758
} from '../domain/user';
@@ -88,6 +89,7 @@ const userResolvers = {
8889
roles: (current, args, context) => rolesUsersLoader.load(current.id, context, context.user, args),
8990
groups: (current, args, context) => userGroupsPaginated(context, context.user, current.id, args),
9091
objectOrganization: (current, args, context) => userOrganizationsPaginated(context, context.user, current.id, args),
92+
objectAssignedOrganization: (current, args, context) => userOrganizationsPaginatedWithoutInferences(context, context.user, current.id, args),
9193
editContext: (current) => fetchEditContext(current.id),
9294
sessions: (current) => findUserSessions(current.id),
9395
effective_confidence_level: (current, args, context) => usersConfidenceLoader.load(current, context, context.user),

opencti-platform/opencti-graphql/src/types/user.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ interface AuthUser extends BasicStoreIdentifier {
3535
roles: Array<UserRole>
3636
groups: Array<Group>
3737
organizations: Array<BasicStoreCommon>
38-
allowed_organizations: Array<BasicStoreCommon>
3938
administrated_organizations: Array<BasicStoreCommon>
4039
capabilities: Array<UserCapability>
4140
allowed_marking: Array<StoreMarkingDefinition>

opencti-platform/opencti-graphql/src/utils/access.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ export const SYSTEM_USER: AuthUser = {
9191
groups: [],
9292
capabilities: [{ name: BYPASS }],
9393
organizations: [],
94-
allowed_organizations: [],
9594
allowed_marking: [],
9695
default_marking: [],
9796
max_shareable_marking: [],
@@ -125,7 +124,6 @@ export const RETENTION_MANAGER_USER: AuthUser = {
125124
groups: [],
126125
capabilities: [{ name: BYPASS }],
127126
organizations: [],
128-
allowed_organizations: [],
129127
allowed_marking: [],
130128
max_shareable_marking: [],
131129
default_marking: [],
@@ -159,7 +157,6 @@ export const RULE_MANAGER_USER: AuthUser = {
159157
groups: [],
160158
capabilities: [{ name: BYPASS }],
161159
organizations: [],
162-
allowed_organizations: [],
163160
allowed_marking: [],
164161
max_shareable_marking: [],
165162
default_marking: [],
@@ -193,7 +190,6 @@ export const AUTOMATION_MANAGER_USER: AuthUser = {
193190
groups: [],
194191
capabilities: [{ name: BYPASS }],
195192
organizations: [],
196-
allowed_organizations: [],
197193
allowed_marking: [],
198194
max_shareable_marking: [],
199195
default_marking: [],
@@ -227,7 +223,6 @@ export const DECAY_MANAGER_USER: AuthUser = {
227223
groups: [],
228224
capabilities: [{ name: BYPASS }],
229225
organizations: [],
230-
allowed_organizations: [],
231226
allowed_marking: [],
232227
max_shareable_marking: [],
233228
default_marking: [],
@@ -261,7 +256,6 @@ export const GARBAGE_COLLECTION_MANAGER_USER: AuthUser = {
261256
groups: [],
262257
capabilities: [{ name: BYPASS }],
263258
organizations: [],
264-
allowed_organizations: [],
265259
allowed_marking: [],
266260
max_shareable_marking: [],
267261
default_marking: [],
@@ -296,7 +290,6 @@ export const REDACTED_USER: AuthUser = {
296290
groups: [],
297291
capabilities: [],
298292
organizations: [],
299-
allowed_organizations: [],
300293
allowed_marking: [],
301294
max_shareable_marking: [],
302295
default_marking: [],
@@ -323,7 +316,6 @@ export const TELEMETRY_MANAGER_USER: AuthUser = {
323316
groups: [],
324317
capabilities: [{ name: BYPASS }],
325318
organizations: [],
326-
allowed_organizations: [],
327319
allowed_marking: [],
328320
max_shareable_marking: [],
329321
default_marking: [],
@@ -433,7 +425,7 @@ export const userFilterStoreElements = async (context: AuthContext, user: AuthUs
433425
}
434426
// Check restricted elements
435427
const elementOrganizations = element[RELATION_GRANTED_TO] ?? [];
436-
const userOrganizations = user.allowed_organizations.map((o) => o.internal_id);
428+
const userOrganizations = user.organizations.map((o) => o.internal_id);
437429
// If platform organization is set
438430
if (settings.platform_organization) {
439431
// If user part of platform organization, is granted by default
@@ -488,7 +480,7 @@ export const isUserCanAccessStixElement = async (context: AuthContext, user: Aut
488480
// Check restricted elements
489481
const settings = await getEntityFromCache<BasicStoreSettings>(context, user, ENTITY_TYPE_SETTINGS);
490482
const elementOrganizations = instance.extensions?.[STIX_EXT_OCTI]?.granted_refs ?? [];
491-
const userOrganizations = user.allowed_organizations.map((o) => o.standard_id);
483+
const userOrganizations = user.organizations.map((o) => o.standard_id);
492484
// If platform organization is set
493485
if (settings.platform_organization) {
494486
// If user part of platform organization, is granted by default
@@ -509,8 +501,8 @@ export const isUserCanAccessStixElement = async (context: AuthContext, user: Aut
509501
// returns all user member access ids : his id, his organizations ids (and parent organizations), his groups ids
510502
export const computeUserMemberAccessIds = (user: AuthUser) => {
511503
const memberAccessIds = [user.id];
512-
if (user.allowed_organizations) {
513-
const userOrganizationsIds = user.allowed_organizations.map((org) => org.internal_id);
504+
if (user.organizations) {
505+
const userOrganizationsIds = user.organizations.map((org) => org.internal_id);
514506
memberAccessIds.push(...userOrganizationsIds);
515507
}
516508
if (user.groups) {

opencti-platform/opencti-graphql/tests/02-integration/01-database/file-storage-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ describe('File storage file listing', () => {
111111
user_email: 'user-no-capa@opencti.io',
112112
inside_platform_organization: true,
113113
allowed_marking: [],
114-
allowed_organizations: [],
115114
roles: [{ internal_id: '08f558bc-b93d-40dc-8e86-f70309d9e1a6', id: '08f558bc-b93d-40dc-8e86-f70309d9e1a6', name: 'No capa' }],
116115
groups: [],
117116
capabilities: [],

0 commit comments

Comments
 (0)