Skip to content

Commit 4707bf5

Browse files
[backend] improve organization sharing (#4538)
1 parent 0ebdb6c commit 4707bf5

File tree

5 files changed

+666
-581
lines changed

5 files changed

+666
-581
lines changed

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

-21
Original file line numberDiff line numberDiff line change
@@ -504,27 +504,6 @@ export const buildDataRestrictions = async (context, user, opts = {}) => {
504504
// Finally build the bool should search
505505
must.push({ bool: { should, minimum_should_match: 1 } });
506506
}
507-
} else {
508-
// Data with Empty granted_refs are granted to everyone
509-
const should = [excludedEntityMatches];
510-
should.push({ bool: { must_not: [{ exists: { field: buildRefRelationSearchKey(RELATION_GRANTED_TO) } }] } });
511-
// Data with granted_refs users that participate to at least one
512-
if (user.allowed_organizations.length > 0) {
513-
const shouldOrgs = user.allowed_organizations
514-
.map((m) => ({ match: { [buildRefRelationSearchKey(RELATION_GRANTED_TO)]: m.internal_id } }));
515-
should.push(...shouldOrgs);
516-
}
517-
// User individual or data created by this individual must be accessible
518-
if (user.individual_id) {
519-
should.push({ match: { 'internal_id.keyword': user.individual_id } });
520-
should.push({ match: { [buildRefRelationSearchKey(RELATION_CREATED_BY)]: user.individual_id } });
521-
}
522-
// For tasks
523-
should.push({ match: { 'initiator_id.keyword': user.internal_id } });
524-
// Access to authorized members
525-
should.push(...buildUserMemberAccessFilter(user, { includeAuthorities: opts?.includeAuthorities, excludeEmptyAuthorizedMembers: true }));
526-
// Finally build the bool should search
527-
must.push({ bool: { should, minimum_should_match: 1 } });
528507
}
529508
// endregion
530509
}

0 commit comments

Comments
 (0)