feat: Implement API client and token models with hashing and JWT authentication

- Added ApiClientModel and ApiTokenModel for managing API clients and tokens.
- Introduced ConfigurationDefinitionModel and ConfigurationValueModel for configuration management.
- Created CredentialSecretModel for storing credential secrets.
- Developed DeploymentArtifactModel and DeploymentBatchModel for deployment management.
- Enhanced DeploymentTargetModel and DeploymentTemplateSelectionModel to support template revisions.
- Added TemplateRevisionModel and TemplateVersionModel for versioning templates.
- Implemented ApiClientSecretHasher for secure secret hashing.
- Created ApiTokenService for generating and validating JWT tokens.
- Updated QueueJobService to handle deployment requests with artifacts.
- Configured authentication settings in appsettings.json for JWT and Negotiate authentication.
This commit is contained in:
Torsten Brendgen
2026-07-09 14:44:38 +02:00
parent 1aa2adac08
commit dc93ea0813
72 changed files with 32906 additions and 516 deletions

View File

@@ -0,0 +1,11 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.Auth
{
public class CreateManagedTokenRequestDto
{
public string Name { get; set; } = string.Empty;
public string Scope { get; set; } = string.Empty;
public DateTime? ExpiresAt { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.Auth
{
public class CreateManagedTokenResponseDto
{
public Guid Id { get; set; }
public string AccessToken { get; set; } = string.Empty;
public string TokenType { get; set; } = "Bearer";
public int ExpiresIn { get; set; }
public DateTime ExpiresAt { get; set; }
public string Scope { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,29 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.Auth
{
public class GetManagedTokenDto
{
public Guid Id { get; set; }
public string Subject { get; set; } = string.Empty;
public string SubjectType { get; set; } = string.Empty;
public string? ClientId { get; set; }
public string Name { get; set; } = string.Empty;
public string Scope { get; set; } = string.Empty;
public DateTime IssuedAt { get; set; }
public DateTime ExpiresAt { get; set; }
public DateTime? RevokedAt { get; set; }
public string? RevokedBy { get; set; }
public DateTime? LastUsedAt { get; set; }
public bool IsActive { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.Auth
{
public class TokenRequestDto
{
public string ClientId { get; set; } = string.Empty;
public string ClientSecret { get; set; } = string.Empty;
public string? Scope { get; set; }
}
}

View File

@@ -0,0 +1,10 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.Auth
{
public class TokenResponseDto
{
public string AccessToken { get; set; } = string.Empty;
public string TokenType { get; set; } = "Bearer";
public int ExpiresIn { get; set; }
public string Scope { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,10 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.ConfigurationDefinition.Add
{
public class AddConfigurationDefinitionDto
{
public Guid? TemplateRevisionId { get; set; }
public string Kind { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string PropertiesJson { get; set; } = "{}";
}
}

View File

@@ -0,0 +1,10 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.ConfigurationDefinition.Edit
{
public class EditConfigurationDefinitionDto
{
public Guid? TemplateRevisionId { get; set; }
public string Kind { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string PropertiesJson { get; set; } = "{}";
}
}

View File

@@ -0,0 +1,13 @@
using Microsoft.SelfService.Portal.Core.API.Dto;
namespace Microsoft.SelfService.Portal.Core.API.Dto.ConfigurationDefinition.Get
{
public class GetConfigurationDefinitionDto : BaseDetailsDto
{
public Guid? TemplateRevisionId { get; set; }
public string Kind { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public string PropertiesJson { get; set; } = "{}";
public string DefinitionHash { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,13 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.ConfigurationValue.Add
{
public class AddConfigurationValueDto
{
public Guid ConfigurationDefinitionId { get; set; }
public string ScopeType { get; set; } = "TemplateRevision";
public Guid ScopeId { get; set; }
public string ValueSourceType { get; set; } = "Static";
public string? SourcePath { get; set; }
public string? ValueJson { get; set; }
public int SortOrder { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
using Microsoft.SelfService.Portal.Core.API.Dto;
namespace Microsoft.SelfService.Portal.Core.API.Dto.ConfigurationValue.Get
{
public class GetConfigurationValueDto : BaseDetailsDto
{
public Guid ConfigurationDefinitionId { get; set; }
public string ScopeType { get; set; } = string.Empty;
public Guid ScopeId { get; set; }
public string ValueSourceType { get; set; } = string.Empty;
public string? SourcePath { get; set; }
public string? ValueJson { get; set; }
public string ValueHash { get; set; } = string.Empty;
public int SortOrder { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.CredentialSecret.Add
{
public class AddCredentialSecretDto
{
public string Name { get; set; } = string.Empty;
public string? UserName { get; set; }
public string SecretValue { get; set; } = string.Empty;
public string SecretType { get; set; } = "Credential";
public string? MetadataJson { get; set; }
public bool IsEnabled { get; set; } = true;
}
}

View File

@@ -0,0 +1,13 @@
using Microsoft.SelfService.Portal.Core.API.Dto;
namespace Microsoft.SelfService.Portal.Core.API.Dto.CredentialSecret.Get
{
public class GetCredentialSecretDto : BaseDetailsDto
{
public string Name { get; set; } = string.Empty;
public string? UserName { get; set; }
public string SecretType { get; set; } = "Credential";
public string? MetadataJson { get; set; }
public bool IsEnabled { get; set; }
}
}

View File

@@ -0,0 +1,11 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.CredentialSecret.Get
{
public class GetCredentialSecretValueDto
{
public string Name { get; set; } = string.Empty;
public string? UserName { get; set; }
public string SecretValue { get; set; } = string.Empty;
public string SecretType { get; set; } = "Credential";
public string? MetadataJson { get; set; }
}
}

View File

@@ -3,6 +3,7 @@
public class AddDeploymentRequestDto
{
public Guid DeploymentGroupId { get; set; }
public Guid? DeploymentArtifactId { get; set; }
public ICollection<Guid> TargetIds { get; set; } = new List<Guid>();
public string JsonData { get; set; } = "{}";
}

View File

@@ -0,0 +1,14 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.DeploymentArtifact.Add
{
public class AddDeploymentArtifactDto
{
public Guid DeploymentGroupId { get; set; }
public Guid? TargetId { get; set; }
public string ArtifactType { get; set; } = "ResolvedConfigurationData";
public string Status { get; set; } = "Pending";
public string DeploymentJson { get; set; } = "{}";
public string? SourceJson { get; set; }
public string? ResolvedJson { get; set; }
public string? SourceSnapshotJson { get; set; }
}
}

View File

@@ -0,0 +1,20 @@
using Microsoft.SelfService.Portal.Core.API.Dto;
namespace Microsoft.SelfService.Portal.Core.API.Dto.DeploymentArtifact.Get
{
public class GetDeploymentArtifactDto : BaseDetailsDto
{
public Guid DeploymentGroupId { get; set; }
public Guid? TargetId { get; set; }
public string ArtifactType { get; set; } = string.Empty;
public string Status { get; set; } = string.Empty;
public string DeploymentJson { get; set; } = "{}";
public string? SourceJson { get; set; }
public string? ResolvedJson { get; set; }
public string? SourceSnapshotJson { get; set; }
public string InputHash { get; set; } = string.Empty;
public string OutputHash { get; set; } = string.Empty;
public bool IsStale { get; set; }
public string? StaleReasonJson { get; set; }
}
}

View File

@@ -3,6 +3,7 @@
public class AddDeploymentTemplateSelectionDto
{
public Guid TemplateVersionId { get; set; }
public Guid? TemplateRevisionId { get; set; }
public string TemplateRole { get; set; } = "Service";
public int SortOrder { get; set; }
public string? Alias { get; set; }

View File

@@ -6,6 +6,7 @@ namespace Microsoft.SelfService.Portal.Core.API.Dto.DeploymentComposition.Get
{
public Guid DeploymentGroupId { get; set; }
public Guid TemplateVersionId { get; set; }
public Guid? TemplateRevisionId { get; set; }
public string TemplateRole { get; set; } = string.Empty;
public int SortOrder { get; set; }
public string? Alias { get; set; }

View File

@@ -0,0 +1,10 @@
namespace Microsoft.SelfService.Portal.Core.API.Dto.TemplateRevision.Add
{
public class AddTemplateRevisionDto
{
public string JsonData { get; set; } = "{}";
public string SchemaVersion { get; set; } = "1.0";
public bool Publish { get; set; }
public string? PublishedBy { get; set; }
}
}

View File

@@ -0,0 +1,17 @@
using Microsoft.SelfService.Portal.Core.API.Dto;
namespace Microsoft.SelfService.Portal.Core.API.Dto.TemplateRevision.Get
{
public class GetTemplateRevisionDto : BaseDetailsDto
{
public Guid TemplateVersionId { get; set; }
public int RevisionNumber { get; set; }
public string JsonData { get; set; } = "{}";
public string JsonHash { get; set; } = string.Empty;
public string SchemaVersion { get; set; } = "1.0";
public bool IsCurrent { get; set; }
public bool IsPublished { get; set; }
public DateTime? PublishedAt { get; set; }
public string? PublishedBy { get; set; }
}
}