Merge remote-tracking branch 'origin/main' into fix/agent-systemd-credentials
Heimdall Gitea / Build and tests (pull_request) Failing after 7m9s
Heimdall Gitea / Publish versioned release (pull_request) Skipped

# Conflicts:
#	install/install-agent.sh
#	src/Heimdall.Agent/AgentOptions.cs
This commit is contained in:
Arnaud Dartois committed 2026-10-22 19:14:27 +02:00
commit 7262c6dc55
8 files changed
+36 -12

No files matched your search

+4
View File
@@ -16,7 +16,11 @@ public sealed class AgentOptions
[Required, Url]
public string CentralUrl { get; init; } = string.Empty;
/// <summary>Allow an unencrypted HTTP Central URL for isolated development networks only.</summary>
public bool AllowInsecureHttp { get; init; }
/// <summary>Site token for initial agent registration.</summary>
[Required, MinLength(1)]
public string SiteToken
{
get => string.IsNullOrWhiteSpace(_siteToken)
+4
View File
@@ -39,6 +39,10 @@ if (!string.IsNullOrEmpty(sentryDsn))
builder.Services.AddOptions<AgentOptions>()
.BindConfiguration(AgentOptions.SectionName)
.ValidateDataAnnotations()
.Validate(options => Uri.TryCreate(options.CentralUrl, UriKind.Absolute, out var centralUri) &&
(centralUri.Scheme == Uri.UriSchemeHttps ||
(options.AllowInsecureHttp && centralUri.Scheme == Uri.UriSchemeHttp)),
"Agent:CentralUrl must use HTTPS unless Agent:AllowInsecureHttp is explicitly enabled.")
.ValidateOnStart();
// HTTP clients
@@ -21,7 +21,11 @@ public class UserRepository : IUserRepository
public async Task<PagedResult<UserResponse>> GetPagedAsync(int page, int pageSize, CancellationToken ct)
{
var query = _db.Users.AsNoTracking().OrderBy(u => u.DisplayName);
// Keep newly created accounts visible on the first page immediately after
// creation, even when the installation has more users than one page.
var query = _db.Users.AsNoTracking()
.OrderByDescending(u => u.CreatedAt)
.ThenBy(u => u.Id);
var total = await query.CountAsync(ct).ConfigureAwait(false);
var users = await query
.Skip((page - 1) * pageSize)
@@ -84,7 +84,7 @@
}
private string ShellCommand
=> $"curl -sSL {CentralUrl}/install-agent.sh -o install-agent.sh && bash install-agent.sh --site-token {SiteToken} --name \"{SiteName}\"";
=> $"curl -sSL {ShellQuote(CentralUrl.TrimEnd('/') + "/install-agent.sh")} -o install-agent.sh && bash install-agent.sh --central-url {ShellQuote(CentralUrl)} --site-token {ShellQuote(SiteToken)} --agent-name {ShellQuote(SiteName)}";
private async Task CopyCode(string code)
{
@@ -101,4 +101,7 @@
sb.Append(char.IsLetterOrDigit(ch) ? ch : '-');
return sb.ToString().Trim('-');
}
private static string ShellQuote(string value)
=> $"'{value.Replace("'", "'\\''", StringComparison.Ordinal)}'";
}