Restructure into src/tests and add build foundation (M0)

Moves the scaffold to src/DodoSSH.Api and establishes the repo conventions the rest
of the milestones build on.

Structure:
- src/{Contracts,Crypto,Domain,Infrastructure,Api}, tests/{Contracts,Crypto,Domain}.Tests
- DodoSSH.slnx rewritten with src/ and tests/ solution folders

Build:
- Directory.Build.props centralises TFM, nullable, deterministic builds and
  TreatWarningsAsErrors; Directory.Packages.props pins every version centrally
- packages.lock.json committed so CI restores in locked mode
- NuGet.config clears machine-level sources, which both fixes NU1507 under central
  package management and makes restore reproducible off this machine
- Microsoft.OpenApi pinned to 2.11.0: ASP.NET Core 10.0.10 resolves 2.0.0, which is
  covered by GHSA-v5pm-xwqc-g5wc (high, patched in 2.7.5)

Analyzers:
- AnalysisLevel is Recommended, not All. With warnings-as-errors, All turns opinionated
  naming rules into build breaks and trains people to blanket-suppress.
- BannedSymbols.txt bans DateTime.UtcNow (TimeProvider), Guid.NewGuid (CreateVersion7),
  sync-over-async, MD5/SHA1, PBKDF2 and SecureString
- CA1711/CA1724 disabled: both are .NET Framework CAS-era naming rules
- PublicApiAnalyzers on Contracts only, since that assembly is the client's real contract

API:
- weather-forecast template removed
- UseHttpsRedirection removed; TLS terminates at the reverse proxy and redirecting
  behind one causes loops
- /healthz/{live,ready,startup}. Liveness deliberately checks no dependencies so a
  transient database outage cannot restart the container and kill live SSH sessions.

Notes:
- No coverage collector yet. Microsoft.Testing.Extensions.CodeCoverage pulls an MTP 1.x
  MSBuild extension that throws TypeLoadException against the MTP 2.3.x xunit.v3 brings.
  Coverage gates are an M3 concern; revisit with an MTP 2.x-aligned version then.

Verified: dotnet build (0 warnings), 17 tests pass, format check clean, API serves
health and OpenAPI endpoints.
This commit is contained in:
2026-07-28 12:25:34 +02:00
parent 1138291d79
commit 3a81f3c90b
43 changed files with 1714 additions and 62 deletions
@@ -0,0 +1,41 @@
namespace DodoSSH.Domain.Authorization;
/// <summary>
/// PermissionFlags a subject (user or team) may hold over a vault or an individual resource.
/// </summary>
/// <remarks>
/// <para>
/// Evaluation is a plain union across the subject's direct grants and the grants held by
/// teams they belong to. There are deliberately no Deny rules: union-only evaluation is
/// monotonic and straightforward to test, and Deny can be added later additively if a
/// real need appears. Express restriction by granting narrowly instead.
/// </para>
/// <para>
/// <see cref="Connect"/> is a user-interface hint, <b>not</b> a security boundary. SSH
/// terminates on the client, so opening a session requires the credential's plaintext on
/// that machine; "may connect but may not view the key" is therefore unenforceable in
/// this architecture. Treat it as an anti-shoulder-surfing convenience and never document
/// it as access control. See docs/adr/0001-e2ee-trust-model.md.
/// </para>
/// </remarks>
[Flags]
public enum PermissionFlags
{
/// <summary>No access.</summary>
None = 0,
/// <summary>May fetch and decrypt the resource. Implies the ability to use it.</summary>
Read = 1 << 0,
/// <summary>May create, modify and soft-delete resources in the vault.</summary>
Write = 1 << 1,
/// <summary>Intent hint that the subject uses this host for sessions. Not a boundary.</summary>
Connect = 1 << 2,
/// <summary>May grant access to other subjects, which requires re-wrapping the vault key.</summary>
Share = 1 << 3,
/// <summary>May administer the vault itself: rename, rekey, manage ACLs.</summary>
Admin = 1 << 4,
}
+12
View File
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Entities, enums and invariants. No EF Core reference: persistence concerns live in
DodoSSH.Infrastructure so the domain stays unit-testable with no database.
-->
<ItemGroup>
<InternalsVisibleTo Include="DodoSSH.Domain.Tests" />
</ItemGroup>
</Project>
+19
View File
@@ -0,0 +1,19 @@
{
"version": 2,
"dependencies": {
"net10.0": {
"Meziantou.Analyzer": {
"type": "Direct",
"requested": "[3.0.134, )",
"resolved": "3.0.134",
"contentHash": "tTYCcYKyOko3TMNxmxmA9nakbcHVUgglENmCMIhzIjl9y9FBZO/0tWSxTGC74Sp198FmWih5S5KkjQRBg5ePkQ=="
},
"Microsoft.CodeAnalysis.BannedApiAnalyzers": {
"type": "Direct",
"requested": "[5.6.0, )",
"resolved": "5.6.0",
"contentHash": "Kcobt3pnOdO0A+6CKiMHZdTEluJpsfxiV20axtZdmfBQnDmiWTKPJADlgAfdTuKNAnVarrkJa0UEGwuOo91muw=="
}
}
}
}