Skip to content

Commit ff2d9fe

Browse files
Merge branch 'fix_security_coroutine_context' into v2
2 parents 9b18e64 + 17de652 commit ff2d9fe

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ group = "com.cosmotech"
3939
version = scmVersion.version
4040

4141
val kotlinJvmTarget = 17
42-
val cosmotechApiCommonVersion = "0.1.27-SNAPSHOT"
42+
val cosmotechApiCommonVersion = "0.1.28-SNAPSHOT"
4343
val cosmotechApiAzureVersion = "0.1.7-SNAPSHOT"
4444
val azureSpringBootBomVersion = "3.14.0"
4545

scenariorun/src/main/kotlin/com/cosmotech/scenariorun/azure/ScenarioRunServiceImpl.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.cosmotech.api.events.WorkflowPhaseToStateRequest
2727
import com.cosmotech.api.exceptions.CsmAccessForbiddenException
2828
import com.cosmotech.api.scenario.ScenarioRunMetaData
2929
import com.cosmotech.api.scenariorun.DataIngestionState
30+
import com.cosmotech.api.security.coroutine.SecurityCoroutineContext
3031
import com.cosmotech.api.utils.convertToMap
3132
import com.cosmotech.api.utils.getCurrentAuthenticatedUserName
3233
import com.cosmotech.api.utils.toDomain
@@ -482,7 +483,7 @@ internal class ScenarioRunServiceImpl(
482483
startInfo.runTemplate.deleteHistoricalData ?: DeleteHistoricalData()
483484
if (purgeHistoricalDataConfiguration.enable) {
484485
logger.debug("Start coroutine to poll simulation status")
485-
GlobalScope.launch {
486+
GlobalScope.launch(SecurityCoroutineContext()) {
486487
withTimeout(
487488
purgeHistoricalDataConfiguration.timeOut?.toLong()
488489
?: DELETE_SCENARIO_RUN_DEFAULT_TIMEOUT) {
@@ -713,12 +714,12 @@ internal class ScenarioRunServiceImpl(
713714
fun onScenarioDeleted(event: ScenarioDeleted) {
714715
logger.debug(
715716
"Caught ScenarioDeleted event => deleting all runs linked to scenario {}", event.scenarioId)
716-
runBlocking {
717+
runBlocking(SecurityCoroutineContext()) {
717718
val jobs =
718719
this@ScenarioRunServiceImpl.getScenarioRuns(
719720
event.organizationId, event.workspaceId, event.scenarioId)
720721
.map { scenarioRun ->
721-
GlobalScope.launch {
722+
GlobalScope.launch(SecurityCoroutineContext()) {
722723
// TODO Consider using a smaller coroutine scope
723724
this@ScenarioRunServiceImpl.deleteScenarioRunWithoutAccessEnforcement(scenarioRun)
724725
}

workspace/src/main/kotlin/com/cosmotech/workspace/azure/WorkspaceServiceImpl.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import com.cosmotech.api.rbac.getCommonRolesDefinition
3333
import com.cosmotech.api.rbac.getPermissions
3434
import com.cosmotech.api.rbac.model.RbacAccessControl
3535
import com.cosmotech.api.rbac.model.RbacSecurity
36+
import com.cosmotech.api.security.coroutine.SecurityCoroutineContext
3637
import com.cosmotech.api.utils.ResourceScanner
3738
import com.cosmotech.api.utils.SecretManager
3839
import com.cosmotech.api.utils.compareToAndMutateIfNeeded
@@ -139,7 +140,7 @@ internal class WorkspaceServiceImpl(
139140
csmRbac.verify(workspace.getRbac(), PERMISSION_WRITE)
140141
logger.debug("Deleting all files for workspace #{} ({})", workspace.id, workspace.name)
141142

142-
GlobalScope.launch {
143+
GlobalScope.launch(SecurityCoroutineContext()) {
143144
// TODO Consider using a smaller coroutine scope
144145
val workspaceFiles =
145146
getWorkspaceFileResources(organizationId, workspaceId).map { it.url }.map {

0 commit comments

Comments
 (0)