fix: bound Subject database retention to synchronous plugin checks
This commit is contained in:
@@ -955,8 +955,10 @@ impl WorkspaceApi {
|
|||||||
"foreign Plugin Worker".into(),
|
"foreign Plugin Worker".into(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
super::plugin_host::with_authority_database(&api, || {
|
||||||
plugin_execution_identity(&api, &worker).map_err(|error| error.error)
|
plugin_execution_identity(&api, &worker).map_err(|error| error.error)
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,6 +134,20 @@ fn operation_name(op: &PluginHostOperation) -> &'static str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retain the physical Subject database only for this synchronous check. Each
|
||||||
|
/// policy/lineage query still reads its owner; no authorization result or lock
|
||||||
|
/// survives the closure, and FeatureStorage continues to enforce lifecycle fences.
|
||||||
|
pub(super) fn with_authority_database<T>(
|
||||||
|
api: &WorkspaceApi,
|
||||||
|
check: impl FnOnce() -> crate::Result<T>,
|
||||||
|
) -> crate::Result<T> {
|
||||||
|
let _database = api
|
||||||
|
.feature_storage
|
||||||
|
.open(&api.subjektiv_registration)
|
||||||
|
.map_err(|error| Error::Store(error.to_string()))?;
|
||||||
|
check()
|
||||||
|
}
|
||||||
|
|
||||||
async fn check(
|
async fn check(
|
||||||
api: Arc<WorkspaceApi>,
|
api: Arc<WorkspaceApi>,
|
||||||
context: ServerRequestContext,
|
context: ServerRequestContext,
|
||||||
@@ -220,12 +234,14 @@ async fn check_tools(
|
|||||||
let executor = api.config_store.db_executor();
|
let executor = api.config_store.db_executor();
|
||||||
executor
|
executor
|
||||||
.run(move || {
|
.run(move || {
|
||||||
|
with_authority_database(&api, || {
|
||||||
subject_authorization::authorize_scope(
|
subject_authorization::authorize_scope(
|
||||||
&api,
|
&api,
|
||||||
&worker,
|
&worker,
|
||||||
&server_api::authorization::OperationAuthorizationRequest {
|
&server_api::authorization::OperationAuthorizationRequest {
|
||||||
operation: operation_name(&operation).into(),
|
operation: operation_name(&operation).into(),
|
||||||
resource: server_api::authorization::PermissionResource::PluginInstallation {
|
resource:
|
||||||
|
server_api::authorization::PermissionResource::PluginInstallation {
|
||||||
workspace_id: workspace.clone(),
|
workspace_id: workspace.clone(),
|
||||||
installation_id: installation.clone(),
|
installation_id: installation.clone(),
|
||||||
},
|
},
|
||||||
@@ -244,6 +260,7 @@ async fn check_tools(
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(policy::map_error)
|
.map_err(policy::map_error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ async fn check_service(
|
|||||||
let executor = api.config_store.db_executor();
|
let executor = api.config_store.db_executor();
|
||||||
executor
|
executor
|
||||||
.run(move || {
|
.run(move || {
|
||||||
|
with_authority_database(&api, || {
|
||||||
for op in ["plugin.service.consume", operation_name(&operation)] {
|
for op in ["plugin.service.consume", operation_name(&operation)] {
|
||||||
subject_authorization::authorize_scope(
|
subject_authorization::authorize_scope(
|
||||||
&api,
|
&api,
|
||||||
@@ -57,6 +58,7 @@ async fn check_service(
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.await
|
.await
|
||||||
.map_err(policy::map_error)
|
.map_err(policy::map_error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user