diff --git a/Directory.Build.props b/Directory.Build.props index 3ad4194..e8729ad 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ latest true - 2026.1.1 + 2026.2.0 true true snupkg diff --git a/example/SeqEnableAAD/Program.cs b/example/SeqEnableAAD/Program.cs index 1e8523f..4d10d6a 100644 --- a/example/SeqEnableAAD/Program.cs +++ b/example/SeqEnableAAD/Program.cs @@ -54,10 +54,10 @@ static async Task Run(string server, string? username, string? tenantId, string? var user = await connection.Users.FindCurrentAsync(); var provider = await connection.Settings.FindNamedAsync(SettingName.AuthenticationProvider); - var cid = await connection.Settings.FindNamedAsync(SettingName.EntraIDClientId); - var ckey = await connection.Settings.FindNamedAsync(SettingName.EntraIDClientKey); - var aut = await connection.Settings.FindNamedAsync(SettingName.EntraIDAuthority); - var tid = await connection.Settings.FindNamedAsync(SettingName.EntraIDTenantId); + var cid = await connection.Settings.FindNamedAsync(SettingName.EntraIdClientId); + var ckey = await connection.Settings.FindNamedAsync(SettingName.EntraIdClientKey); + var aut = await connection.Settings.FindNamedAsync(SettingName.EntraIdAuthority); + var tid = await connection.Settings.FindNamedAsync(SettingName.EntraIdTenantId); user.Username = username; provider.Value = "Microsoft Entra ID"; diff --git a/src/Seq.Api/Client/SeqApiClient.cs b/src/Seq.Api/Client/SeqApiClient.cs index 14f2c70..ab4f659 100644 --- a/src/Seq.Api/Client/SeqApiClient.cs +++ b/src/Seq.Api/Client/SeqApiClient.cs @@ -41,7 +41,7 @@ public sealed class SeqApiClient : IDisposable // Future versions of Seq may not completely support vN-1 features, however // providing this as an Accept header will ensure what compatibility is available // can be utilized. - const string SeqApiVersionedMediaType = "application/vnd.datalust.seq.v14+json"; + const string SeqApiVersionedMediaType = "application/vnd.datalust.seq.v15+json"; const string ApiKeyHeaderName = "X-Seq-ApiKey"; const string CsrfTokenHeaderName = "X-Seq-CsrfToken"; diff --git a/src/Seq.Api/Model/Events/EventEntity.cs b/src/Seq.Api/Model/Events/EventEntity.cs index fbfa96b..3ee1cad 100644 --- a/src/Seq.Api/Model/Events/EventEntity.cs +++ b/src/Seq.Api/Model/Events/EventEntity.cs @@ -95,6 +95,12 @@ public class EventEntity : Entity /// [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public string SpanKind { get; set; } + + /// + /// If the event is a span, any links it carries. + /// + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public List SpanLinks { get; set; } /// /// A collection of properties describing the origin of the event, if any. These correspond to resource diff --git a/src/Seq.Api/Model/Indexes/IndexEntity.cs b/src/Seq.Api/Model/Indexes/IndexEntity.cs index 6b92295..7da1ee4 100644 --- a/src/Seq.Api/Model/Indexes/IndexEntity.cs +++ b/src/Seq.Api/Model/Indexes/IndexEntity.cs @@ -29,5 +29,10 @@ public class IndexEntity: Entity /// The storage used by this index. /// public ulong StorageBytes { get; set; } + + /// + /// If the last attempt at indexing failed to build this index. + /// + public bool IsIndexingFailing { get; set; } } } diff --git a/src/Seq.Api/Model/Settings/AuthenticationSettingsTestResultPart.cs b/src/Seq.Api/Model/Settings/AuthenticationSettingsTestResultPart.cs new file mode 100644 index 0000000..3273b58 --- /dev/null +++ b/src/Seq.Api/Model/Settings/AuthenticationSettingsTestResultPart.cs @@ -0,0 +1,33 @@ +// Copyright © Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Seq.Api.Model.Settings +{ + /// + /// The outcome of testing proposed authentication settings. + /// + public class AuthenticationSettingsTestResultPart + { + /// + /// If true, the settings passed testing. Some aspects of the configuration can only be verified + /// by signing in, so passing does not guarantee that sign-in will work. + /// + public bool Passed { get; set; } + + /// + /// If the test failed, a human-readable description of the problem. + /// + public string Error { get; set; } + } +} diff --git a/src/Seq.Api/Model/Settings/SettingEntity.cs b/src/Seq.Api/Model/Settings/SettingEntity.cs index 11e4153..b399e61 100644 --- a/src/Seq.Api/Model/Settings/SettingEntity.cs +++ b/src/Seq.Api/Model/Settings/SettingEntity.cs @@ -31,5 +31,19 @@ public class SettingEntity : Entity /// The value of the setting. /// public object Value { get; set; } + + /// + /// Indicates that the setting has a value, even when the server redacts that value and + /// returns it as null (the case for passwords and similar secrets). Ignored when + /// saving values: null will always clear a setting, irrespective of the value sent + /// for this property. + /// + public bool HasValue { get; set; } + + /// + /// Indicates that the setting's value is overridden in the server's configuration, and can't be changed through + /// the API. Ignored when saving values. + /// + public bool IsReadOnly { get; set; } } } diff --git a/src/Seq.Api/Model/Settings/SettingName.cs b/src/Seq.Api/Model/Settings/SettingName.cs index 3fc11d4..920fb6c 100644 --- a/src/Seq.Api/Model/Settings/SettingName.cs +++ b/src/Seq.Api/Model/Settings/SettingName.cs @@ -58,29 +58,64 @@ public enum SettingName DataAgeWarningThresholdMilliseconds, /// - /// The Microsoft Entra ID authority. The default is login.windows.net; government cloud users may + /// The Microsoft Entra ID authority. The default is login.microsoftonline.com; government cloud users may /// require login.microsoftonline.us or similar. /// - // ReSharper disable once InconsistentNaming - EntraIDAuthority, + EntraIdAuthority, /// /// The Microsoft Entra ID client id. /// - // ReSharper disable once InconsistentNaming - EntraIDClientId, + EntraIdClientId, /// /// The Microsoft Entra ID client key. /// - // ReSharper disable once InconsistentNaming - EntraIDClientKey, + EntraIdClientKey, /// /// The Microsoft Entra ID tenant id. /// - // ReSharper disable once InconsistentNaming - EntraIDTenantId, + EntraIdTenantId, + + /// + /// The Microsoft Entra ID credential source type. By default (ClientSecret), a client key (client + /// secret) is expected in . Specify SignedAssertionFromManagedIdentity + /// and, optionally, a value for to authenticate using a + /// managed identity instead. If no is specified, the + /// system-assigned managed identity is used. Specify SignedAssertionFile to authenticate using + /// a signed assertion (for example, a Kubernetes projected service account token) read from the file named + /// by the AZURE_FEDERATED_TOKEN_FILE environment variable; the file is re-read on each sign-in so + /// that rotated tokens are picked up. Specify CertificateFile to authenticate using a client + /// certificate and private key from the Seq server's certificates folder. + /// Specify CertificateThumbprint or CertificateSubject to authenticate using a client + /// certificate identified by or + /// , respectively; these options are only supported on Windows. + /// + EntraIdCredentialType, + + /// + /// The client id of the user-assigned managed identity that the app registration's federated identity + /// credential trusts. Considered only when is + /// SignedAssertionFromManagedIdentity. + /// + EntraIdManagedIdentityClientId, + + /// + /// The SHA-1 thumbprint of a client certificate, with private key, in the LocalMachine or + /// CurrentUser Personal (My) Windows certificate store. Considered only when + /// is CertificateThumbprint. + /// + EntraIdClientCertificateThumbprint, + + /// + /// The subject common name, or full distinguished name, of a client certificate in the + /// LocalMachine or CurrentUser Personal (My) Windows certificate store. The newest + /// currently-valid matching certificate with a private key is used, so that rolled-over certificates are + /// picked up automatically. Considered only when is + /// CertificateSubject. + /// + EntraIdClientCertificateSubject, /// /// Server-local filesystem location where automatic backups are stored. @@ -131,6 +166,11 @@ public enum SettingName /// Seq will stop accepting new events. /// MinimumFreeStorageSpace, + + /// + /// The minimum length of passwords for local username/password authentication. + /// + MinimumPasswordLength, /// /// A dictionary of `(string, string)` pairs that will be used to initialize the @@ -192,11 +232,23 @@ public enum SettingName /// list. For example, openid, profile, email. /// OpenIdConnectScopes, + + /// + /// If using OpenID Connect, the URI that the provider will redirect to after the user signs out. + /// + OpenIdConnectEndSessionRedirectUri, /// /// If using OpenID Connect, overrides the URI of the provider's metadata endpoint. /// OpenIdConnectMetadataAddress, + + /// + /// The character classes that local username/password authentication passwords must include, as a string + /// containing any of a (lowercase letter), A (uppercase letter), 0 (digit), and + /// ! (punctuation). + /// + PasswordRequiredCharacterClasses, /// /// If true, ingestion requests incoming via HTTP must be authenticated using an API key or @@ -214,6 +266,22 @@ public enum SettingName /// RawPayloadMaximumContentLength, + /// + /// If true, the SCIM 2.0 user provisioning endpoints under /scim/v2 are enabled. Only + /// effective when is true. + /// + ScimEnabled, + + /// + /// The default duration, in seconds, that searches will cover. + /// + SearchDurationSeconds, + + /// + /// An expression that identifies the service associated with an event or span. + /// + ServiceNameExpression, + /// /// Tracks whether an admin user has dismissed the secret key backup warning. /// @@ -228,6 +296,11 @@ public enum SettingName /// /// A snippet of CSS that will be included in the front-end's user interface styles. /// - ThemeStyles + ThemeStyles, + + /// + /// If true, user avatars will be retrieved from Gravatar. + /// + UseGravatar } } diff --git a/src/Seq.Api/Model/Settings/SettingsValuesPart.cs b/src/Seq.Api/Model/Settings/SettingsValuesPart.cs new file mode 100644 index 0000000..60bd76e --- /dev/null +++ b/src/Seq.Api/Model/Settings/SettingsValuesPart.cs @@ -0,0 +1,48 @@ +// Copyright © Datalust and contributors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Seq.Api.Model.Settings +{ + /// + /// A set of related setting values, to be applied together, or (for authentication settings) tested without being + /// applied. + /// + public class SettingsValuesPart + { + /// + /// Setting values keyed by setting name (see ). Settings that are omitted keep their + /// current values. Settings that are read-only (see ) must be omitted. + /// + /// When testing authentication settings, the AuthenticationProvider setting determines which + /// provider is tested, and settings that don't apply to that provider are ignored. + public Dictionary Settings { get; set; } = new(); + + /// + /// When testing settings for providers that check credentials locally (Active Directory), the username to + /// sign in with. Must be null when applying settings. + /// + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string Username { get; set; } + + /// + /// When testing settings for providers that check credentials locally (Active Directory), the password to + /// sign in with. Must be null when applying settings. + /// + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public string Password { get; set; } + } +} diff --git a/src/Seq.Api/Model/Users/UserEntity.cs b/src/Seq.Api/Model/Users/UserEntity.cs index a86346d..79b9891 100644 --- a/src/Seq.Api/Model/Users/UserEntity.cs +++ b/src/Seq.Api/Model/Users/UserEntity.cs @@ -15,6 +15,7 @@ using System.Collections.Generic; using Newtonsoft.Json; using Seq.Api.Model.Shared; +using Seq.Api.ResourceGroups; namespace Seq.Api.Model.Users { @@ -69,7 +70,17 @@ public class UserEntity : Entity /// The ids of one or more roles that grant permissions to the user. Note that /// the Seq UI currently only supports a single role when editing users. /// - public HashSet RoleIds { get; set; } = new HashSet(); + public HashSet RoleIds { get; set; } = new(); + + /// + /// If true, the user account is deactivated: the user cannot log in. The account and the entities + /// it owns are retained, and the account can be reactivated later. + /// + /// Read-only; changes to this property are ignored when the entity is updated. Use + /// the and actions + /// to change it. + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public bool IsDeactivated { get; set; } /// /// The authentication provider associated with the user account. This will normally be @@ -86,6 +97,15 @@ public class UserEntity : Entity /// [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] public string AuthenticationProviderUniqueIdentifier { get; set; } + + /// + /// The identifier assigned to the user by an external provisioning system (the SCIM externalId), + /// if the account is managed through SCIM. + /// + /// Read-only; the value is set by the provisioning system and changes to this property are + /// ignored when the entity is updated. + [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] + public string ScimExternalId { get; set; } /// /// Because the api/users/login endpoint returns a in the JSON response diff --git a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs index 1d905f8..30ddf5f 100644 --- a/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/DiagnosticsResourceGroup.cs @@ -80,11 +80,10 @@ public async Task GetMeasurementTimeseriesAsync(strin /// extended to account for the resolution of the underlying data. /// /// The (inclusive) start of the range to report on. If omitted, the results will report from the - /// earliest stored data. The range start must land on a five-minute boundary. - /// The (exclusive) end of the range to report on. If omitted, the results will report from the - /// earliest stored data. The range must be a multiple of the interval size, or a whole number of days if - /// no interval is specified. - /// The bucket size to use. Must be a multiple of 5 minutes. Defaults to 1440 (one day). + /// earliest stored data. The range start must land on a storage tick-aligned boundary. + /// The (exclusive) end of the range to report on. If omitted, the results will report to the + /// latest stored data. The range end must lane on a storage tick-aligned boundary. + /// The bucket size to use. Must be a multiple of storage ticks. Defaults to 1440 (one day). A safe minimum value is 300 (5 minutes). /// A allowing the operation to be canceled. /// Storage consumption information. public async Task GetStorageConsumptionAsync( diff --git a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs index 7d4b0e2..6be4907 100644 --- a/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/SettingsResourceGroup.cs @@ -84,5 +84,33 @@ public async Task UpdateInternalErrorReportingAsync(InternalErrorReportingSettin { await GroupPutAsync("InternalErrorReporting", internalErrorReporting, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Update a set of related settings together. Either all of the settings are updated, or none are. Changes to + /// authentication provider settings are applied by reloading the provider, which ends all existing sessions + /// when the provider is OpenID Connect-based. Requires the System permission. + /// + /// The settings to update. The and + /// properties must be null. + /// A allowing the operation to be canceled. + /// A task indicating completion. + public async Task ApplyAsync(SettingsValuesPart values, CancellationToken cancellationToken = default) + { + if (values == null) throw new ArgumentNullException(nameof(values)); + await GroupPostAsync("Apply", values, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// + /// Check that proposed authentication settings can be used successfully, without applying them. Requires + /// the System permission. + /// + /// The proposed settings. + /// A allowing the operation to be canceled. + /// The outcome of the test. + public async Task TestAuthenticationSettingsAsync(SettingsValuesPart test, CancellationToken cancellationToken = default) + { + if (test == null) throw new ArgumentNullException(nameof(test)); + return await GroupPostAsync("AuthTest", test, cancellationToken: cancellationToken).ConfigureAwait(false); + } } } diff --git a/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs b/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs index cf8496f..80e3649 100644 --- a/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs +++ b/src/Seq.Api/ResourceGroups/UsersResourceGroup.cs @@ -187,8 +187,29 @@ public async Task LoginWindowsIntegratedAsync(CancellationToken canc /// A allowing the operation to be canceled. /// A task signalling completion. public async Task UnlinkAuthenticationProviderAsync(UserEntity entity, CancellationToken cancellationToken = default) - { + { await Client.PostAsync(entity, "UnlinkAuthenticationProvider", new {}, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// Deactivate . The user will be unable to log in, their existing + /// sessions are revoked, and API keys they own stop working. The account and everything it owns + /// is retained, and the account can be reactivated with . + /// The user to deactivate. + /// A allowing the operation to be canceled. + /// The updated user. + /// The account the requesting principal acts on behalf of cannot be deactivated. + public async Task DeactivateAsync(UserEntity entity, CancellationToken cancellationToken = default) + { + return await Client.PostAsync(entity, "Deactivate", new {}, cancellationToken: cancellationToken).ConfigureAwait(false); + } + + /// Reactivate a user deactivated with . + /// The user to reactivate. + /// A allowing the operation to be canceled. + /// The updated user. + public async Task ReactivateAsync(UserEntity entity, CancellationToken cancellationToken = default) + { + return await Client.PostAsync(entity, "Reactivate", new {}, cancellationToken: cancellationToken).ConfigureAwait(false); + } } } diff --git a/src/Seq.Api/Seq.Api.csproj b/src/Seq.Api/Seq.Api.csproj index 157f69a..6a269d4 100644 --- a/src/Seq.Api/Seq.Api.csproj +++ b/src/Seq.Api/Seq.Api.csproj @@ -27,8 +27,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/test/Seq.Api.Tests/Seq.Api.Tests.csproj b/test/Seq.Api.Tests/Seq.Api.Tests.csproj index 603b80b..81bdf70 100644 --- a/test/Seq.Api.Tests/Seq.Api.Tests.csproj +++ b/test/Seq.Api.Tests/Seq.Api.Tests.csproj @@ -12,12 +12,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + \ No newline at end of file