Skip to content

Commit 45b399e

Browse files
committed
[backend/frontend] fix(multi-tenancy): custom dashboard API
1 parent ec0ae3c commit 45b399e

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

openaev-api/src/main/java/io/openaev/opencti/connectors/service/PrivilegeService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
@Service
2323
@RequiredArgsConstructor
24+
@Transactional(rollbackFor = Exception.class)
2425
@Slf4j
2526
public class PrivilegeService {
2627

@@ -33,7 +34,10 @@ public class PrivilegeService {
3334
private final TenantUserService tenantUserService;
3435
private final LegacyOpenCTIConnectorMigration legacyOpenCTIConnectorMigration;
3536

36-
@Transactional
37+
/**
38+
* Ensures a privileged technical user exists for the given OpenCTI connector. Creates or updates
39+
* the user, its group, role, and tenant attachment as needed.
40+
*/
3741
public void ensurePrivilegedUserExistsForConnector(ConnectorBase connector) {
3842
Group group = createWellKnownGroupWithRole(createWellKnownRole());
3943
String email = CONNECTOR_EMAIL_PATTERN.formatted(connector.getId());

openaev-api/src/main/java/io/openaev/service/stix/SecurityCoverageService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,14 @@ public void pushSecurityCoverageBundleWithExternalURI(Scenario scenario)
347347
if (tenant == null) {
348348
throw new IllegalStateException("Scenario tenant ID cannot be null");
349349
}
350-
if (openCTIConnectorService.getConnectorBase(tenant.getId()).isEmpty()) {
350+
Optional<ConnectorBase> connector = openCTIConnectorService.getConnectorBase(tenant.getId());
351+
if (connector.isEmpty()) {
352+
return;
353+
}
354+
if (!connector.get().isRegistered()) {
355+
log.warn(
356+
"OpenCTI connector for tenant {} is not registered yet, skipping push of security coverage bundle",
357+
tenant.getId());
351358
return;
352359
}
353360

0 commit comments

Comments
 (0)