Component: Smrt.Security¶
Canonical source:
SmrtApps/src/Smrt.Security/README.md(mirrored below)
Smrt.Security¶
Overview & Responsibilities¶
- Provides shared security helpers consumed by multiple SmrtHub components with no cross-assembly dependencies.
- Current surface area is
WindowsCredentialHelper, a thin wrapper over the Windows Credential Manager (Cred* APIs) for storing opaque secrets. - Follows guidance from
README.Files/System/Policies/SmrtHub-Documentation-Policy-v1.0.README.mdto keep XML documentation authoritative for IDE help and future doc generation.
Public surface¶
The primary public surface is the set of APIs listed under Key APIs below.
Key APIs¶
WindowsCredentialHelper.SaveCredential/UpdateCredentialpersist UTF-16 secrets against a target identifier.WindowsCredentialHelper.GetCredentialretrieves the previously stored secret for the same target, surfacing unexpected Win32 failures asInvalidOperationExceptionwhile returningnullwhen the credential is missing.WindowsCredentialHelper.DeleteCredentialremoves credentials that are no longer required (silently ignores already-removed targets).WindowsCredentialHelper.ListCredentialsenumerates available credential targets for diagnostics and throws when the enumerator returns an unexpected Win32 error so the caller can capture it in logs/support bundles.
Cloud provider credential targets (vNext)¶
Cloud provider secrets are stored in Windows Credential Manager and must not be persisted to config/state/logs.
Credential target naming is owned by Smrt.CloudProviders and follows the vNext spine spec in
README.Files/SmrtHub-vNext-Architecture/Milestone-A-Spine-Spec.md.
Dependencies & Integrations¶
- No third-party packages; uses Windows
advapi32.dllP/Invoke bindings. - Consumers should continue to resolve configuration via
Smrt.Configand log withSmrtHub.Loggingas documented inREADME.Files/Reference-Guides/SmrtHub.Logging.README.md. - Secrets retrieved from this helper must never be written to logs; redaction policies in
README.Files/System/Policies/SmrtHub-Operational-Data-Policy-v1.0.README.mdapply.
Configuration & Log Paths¶
- The helper itself is configuration-free. Calling applications manage settings under
%AppData%/SmrtHub/Config/<slug>and logs under%AppData%/SmrtHub/Logs/<slug>per the Operational Data Policy. - Exceptions expose Win32 error codes to the caller; callers must capture these through
SmrtHub.Logging(without secret values) for traceability.
Runtime Workflow¶
- Normalize the credential target name (for example
smrt-hub/api-gateway). - Call
SaveCredentialwith a UTF-16 secret up to 512 bytes. Optional user name and comment metadata are supported. - Fetch the secret when required via
GetCredential; the helper returnsnullif the credential is missing. - Remove credentials that are no longer valid using
DeleteCredentialso that stale data is not left in the credential vault.
Testing & Validation¶
- Unit tests should focus on validating argument guards and error propagation (mock the Win32 calls or abstract via the partial class pattern).
- Integration tests must run on Windows, create disposable targets, and delete credentials they create to avoid polluting developer machines.
- Manual smoke testing is available via
WindowsCredentialHelper.TestUtility(DEBUG-only) to verify local Credential Manager access after clearing%AppData%/SmrtHubsecrets.
Support Bundle & Diagnostics Touchpoints¶
- Failures surface as
InvalidOperationExceptionwith the Win32 error; calling components should log the error and include results in support bundles generated viaSmrt.SupportBundle. - When investigating issues, capture the component log plus the Support Bundle manifest hashes to confirm which credentials were queried.
Directory Map¶
SmrtHub.Security.WindowsCredentialHelper.cs— public API and P/Invoke bindings.SmrtHub.Security.csproj— library configuration (compiled with XML documentation output).bin/,obj/— generated build output; cleansed by standarddotnet cleanor repository build scripts.
Related docs¶
README.Files/System/Policies/SmrtHub-Privacy-and-Security-Policy.README.mdREADME.Files/System/Policies/SmrtHub-Operational-Data-Policy-v1.0.README.md