merge: integrate access isolation into auth session security
This commit is contained in:
commit
7ecf4ad247
39 files changed
+1081
-497
No files matched your search
@@ -226,7 +226,7 @@ public class AgentsController : ControllerBase
|
||||
public async Task<IActionResult> ListAll(
|
||||
[FromQuery] int page = 1, [FromQuery] int pageSize = 20, CancellationToken ct = default)
|
||||
{
|
||||
var result = await _mediator.Send(new GetAllAgentsQuery(page, pageSize), ct);
|
||||
var result = await _mediator.Send(new GetAllAgentsQuery(page, pageSize, await GetAllowedSites(ct)), ct);
|
||||
if (!result.IsSuccess)
|
||||
return StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
return Ok(result.Data);
|
||||
@@ -245,4 +245,11 @@ public class AgentsController : ControllerBase
|
||||
? Ok()
|
||||
: StatusCode(result.StatusCode ?? 404, new { error = result.Error });
|
||||
}
|
||||
private async Task<List<Guid>> GetAllowedSites(CancellationToken ct)
|
||||
{
|
||||
var access = HttpContext.RequestServices.GetRequiredService<Heimdall.Api.Security.ResourceAccess>();
|
||||
var requester = await access.ResolveAsync(User, ct);
|
||||
return requester is null ? [] : await access.FullSiteIdsAsync(requester, ct);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,13 +89,13 @@ public class SettingsController : ControllerBase
|
||||
public async Task<IActionResult> Create(
|
||||
[FromBody] CreateAppSettingRequest request, CancellationToken ct)
|
||||
{
|
||||
var command = new CreateAppSettingCommand(request.Key, request.Value, request.Category, request.Description, request.ValueType, request.AllowedValues);
|
||||
var command = new CreateAppSettingCommand(request.Key, request.Value, request.Category, request.Description, request.ValueType, request.AllowedValues, request.AgentScoped);
|
||||
var result = await _mediator.Send(command, ct);
|
||||
if (!result.IsSuccess)
|
||||
return StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
|
||||
await _broadcast.NotifyGlobalSettingChanged(result.Data!.Key, result.Data.Value, ct);
|
||||
_logger.LogInformation("Created global setting {Key} = {Value}", result.Data.Key, RedactValue(result.Data.ValueType, result.Data.Value));
|
||||
_logger.LogInformation("Created global setting {Key}", result.Data!.Key);
|
||||
return Ok(result.Data);
|
||||
}
|
||||
|
||||
@@ -108,13 +108,13 @@ public class SettingsController : ControllerBase
|
||||
public async Task<IActionResult> Update(
|
||||
string key, [FromBody] UpdateAppSettingRequest request, CancellationToken ct)
|
||||
{
|
||||
var command = new UpdateAppSettingCommand(key, request.Value, request.Description, request.Category, request.ValueType, request.AllowedValues);
|
||||
var command = new UpdateAppSettingCommand(key, request.Value, request.Description, request.Category, request.ValueType, request.AllowedValues, request.AgentScoped);
|
||||
var result = await _mediator.Send(command, ct);
|
||||
if (!result.IsSuccess)
|
||||
return StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
|
||||
await _broadcast.NotifyGlobalSettingChanged(result.Data!.Key, result.Data.Value, ct);
|
||||
_logger.LogInformation("Updated global setting {Key} = {Value}", result.Data.Key, RedactValue(result.Data.ValueType, result.Data.Value));
|
||||
_logger.LogInformation("Updated global setting {Key}", result.Data!.Key);
|
||||
return Ok(result.Data);
|
||||
}
|
||||
|
||||
@@ -203,8 +203,7 @@ public class SettingsController : ControllerBase
|
||||
return StatusCode(result.StatusCode ?? 400, new { error = result.Error });
|
||||
|
||||
await _broadcast.NotifyAgentSettingChanged(agentId, result.Data!.Key, result.Data.Value, ct);
|
||||
_logger.LogInformation("Set agent override Agent={AgentId}, {Key} = {Value}",
|
||||
agentId, result.Data.Key, RedactValue(null, result.Data.Value, result.Data.Key));
|
||||
_logger.LogInformation("Set agent override Agent={AgentId}, {Key}", agentId, result.Data!.Key);
|
||||
return Ok(result.Data);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user