chore(thalos-dal): checkpoint pending development updates

This commit is contained in:
José René White Enciso 2026-03-09 11:57:46 -06:00
parent ae8bbb1928
commit aac5efb01b
11 changed files with 179 additions and 2 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
**/bin/
**/obj/
.vs/
TestResults/
.git/
.repo-tasks/
.repo-context/
.tasks/
.agile/

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
# syntax=docker/dockerfile:1.7
ARG SDK_IMAGE=mcr.microsoft.com/dotnet/sdk:10.0
ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/aspnet:10.0
FROM ${SDK_IMAGE} AS build
ARG NUGET_FEED_URL=https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json
ARG NUGET_FEED_USERNAME=
ARG NUGET_FEED_TOKEN=
WORKDIR /src
COPY . .
RUN if [ -n "$NUGET_FEED_USERNAME" ] && [ -n "$NUGET_FEED_TOKEN" ]; then dotnet nuget add source "$NUGET_FEED_URL" --name gitea-org --username "$NUGET_FEED_USERNAME" --password "$NUGET_FEED_TOKEN" --store-password-in-clear-text --allow-insecure-connections --configfile /root/.nuget/NuGet/NuGet.Config; fi
RUN dotnet restore "src/Thalos.DAL.Host/Thalos.DAL.Host.csproj" --configfile /root/.nuget/NuGet/NuGet.Config
RUN dotnet publish "src/Thalos.DAL.Host/Thalos.DAL.Host.csproj" -c Release -o /app/publish /p:UseAppHost=false --no-restore
FROM ${RUNTIME_IMAGE} AS runtime
WORKDIR /app
ENV ASPNETCORE_URLS=http://+:8080 ASPNETCORE_ENVIRONMENT=Production
EXPOSE 8080
COPY --from=build /app/publish .
ENTRYPOINT ["dotnet", "Thalos.DAL.Host.dll"]

View File

@ -1,5 +1,6 @@
<Solution> <Solution>
<Folder Name="/src/"> <Folder Name="/src/">
<Project Path="src/Thalos.DAL.Host/Thalos.DAL.Host.csproj" />
<Project Path="src/Thalos.DAL/Thalos.DAL.csproj" /> <Project Path="src/Thalos.DAL/Thalos.DAL.csproj" />
</Folder> </Folder>
<Folder Name="/tests/"> <Folder Name="/tests/">

View File

@ -15,7 +15,7 @@ Remove cross-repo source coupling from `Thalos.DAL` and consume shared contracts
Repository-level `nuget.config` includes: Repository-level `nuget.config` includes:
- `gitea-org`: `http://192.168.10.100:3000/api/packages/AgileWebs/nuget/index.json` - `gitea-org`: `https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json`
- `nuget.org` - `nuget.org`
Because feed is currently HTTP, `allowInsecureConnections="true"` is required for the Gitea source. Because feed is currently HTTP, `allowInsecureConnections="true"` is required for the Gitea source.

View File

@ -0,0 +1,23 @@
# Containerization Runbook
## Image Build
```bash
docker build --build-arg NUGET_FEED_USERNAME=<gitea-login> --build-arg NUGET_FEED_TOKEN=<gitea-token> -t agilewebs/thalos-dal:dev .
```
## Local Run
```bash
docker run --rm -p 8080:8080 --name thalos-dal agilewebs/thalos-dal:dev
```
## Health Probe
- Path: `/health`
- Fallback path: `/healthz`
- Port: `8080`
## Runtime Notes
- Exposes internal DAL lookup endpoints for identity token, policy, and permissions data.

View File

@ -2,7 +2,7 @@
<configuration> <configuration>
<packageSources> <packageSources>
<clear /> <clear />
<add key="gitea-org" value="http://192.168.10.100:3000/api/packages/AgileWebs/nuget/index.json" allowInsecureConnections="true" /> <add key="gitea-org" value="https://gitea.dream-views.com/api/packages/AgileWebs/nuget/index.json" allowInsecureConnections="true" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" /> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources> </packageSources>
</configuration> </configuration>

View File

@ -0,0 +1,71 @@
using Microsoft.Extensions.Primitives;
using Thalos.DAL.Contracts;
using Thalos.DAL.DependencyInjection;
using Thalos.DAL.Repositories;
using IdentityAuthProvider = BuildingBlock.Identity.Contracts.Conventions.IdentityAuthProvider;
const string CorrelationHeaderName = "x-correlation-id";
const string ContractVersion = "v1";
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();
builder.Services.AddThalosDalRuntime();
var app = builder.Build();
app.MapGet("/internal/thalos-dal/token", async (
string subjectId,
string tenantId,
string? externalToken,
IIdentityRepository repository,
HttpContext context,
CancellationToken ct) =>
{
var envelope = new IdentityContractEnvelope(ContractVersion, ResolveCorrelationId(context));
var request = new IdentityTokenLookupRequest(envelope, subjectId, tenantId, IdentityAuthProvider.InternalJwt, externalToken ?? string.Empty);
var record = await repository.ReadIdentityTokenAsync(request, ct);
return record is null ? Results.NotFound() : Results.Ok(record);
});
app.MapGet("/internal/thalos-dal/policy", async (
string subjectId,
string tenantId,
string permissionCode,
IIdentityRepository repository,
HttpContext context,
CancellationToken ct) =>
{
var envelope = new IdentityContractEnvelope(ContractVersion, ResolveCorrelationId(context));
var request = new IdentityPolicyLookupRequest(envelope, subjectId, tenantId, permissionCode);
var record = await repository.ReadIdentityPolicyAsync(request, ct);
return record is null ? Results.NotFound() : Results.Ok(record);
});
app.MapGet("/internal/thalos-dal/permissions", async (
string subjectId,
string tenantId,
IIdentityRepository repository,
HttpContext context,
CancellationToken ct) =>
{
var envelope = new IdentityContractEnvelope(ContractVersion, ResolveCorrelationId(context));
var request = new IdentityPermissionSetLookupRequest(envelope, subjectId, tenantId);
var records = await repository.ReadPermissionSetAsync(request, ct);
return Results.Ok(records);
});
app.MapHealthChecks("/health");
app.MapHealthChecks("/healthz");
app.Run();
static string ResolveCorrelationId(HttpContext context)
{
if (context.Request.Headers.TryGetValue(CorrelationHeaderName, out var headerValue) &&
!StringValues.IsNullOrEmpty(headerValue))
{
return headerValue.ToString();
}
return context.TraceIdentifier;
}

View File

@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:0",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "https://localhost:0;http://localhost:0",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Thalos.DAL\Thalos.DAL.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}