Skip to content

Commit 76a4b9e

Browse files
committed
Validate LDAP account of the initiating user when a task is started. Closes #663.
1 parent 0f0e72f commit 76a4b9e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

atr/worker.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import sqlmodel
3636

3737
import atr.db as db
38+
import atr.ldap as ldap
3839
import atr.log as log
3940
import atr.models.results as results
4041
import atr.models.sql as sql
@@ -229,6 +230,11 @@ async def _task_process(task_id: int, task_type: str, task_args: list[str] | dic
229230

230231
task_results: results.Results | None
231232
try:
233+
if asf_uid != "system":
234+
user_account = await ldap.account_lookup(asf_uid)
235+
if user_account is None or ldap.is_banned(user_account):
236+
raise RuntimeError(f"Account '{asf_uid}' is banned or does not exist")
237+
232238
handler = tasks.resolve(task_type_member)
233239
sig = inspect.signature(handler)
234240
params = list(sig.parameters.values())

0 commit comments

Comments
 (0)