SmrtHub.Security¶
Assembly:
SmrtHub.Security
Namespace: SmrtHub.Security¶
SmrtChatCredentialTargets¶
Canonical Windows Credential Manager target names for SmrtChat BYOK cloud providers.
Fields¶
AnthropicApiKey¶
Credential target for the Anthropic API key.
AwsAccessKeyId¶
Credential target for the AWS access key id.
AwsSecretAccessKey¶
Credential target for the AWS secret access key.
AwsSessionToken¶
Credential target for an AWS session token (optional). This is shared across AWS-backed providers when short-lived STS credentials are used.
AzureOpenAiApiKey¶
Credential target for the Azure OpenAI API key.
GeminiApiKey¶
Credential target for the Gemini API key (Google AI Studio / Gemini API).
GeminiServiceAccountJson¶
Credential target for the Gemini service account JSON (Vertex AI auth flow).
OpenAiApiKey¶
Credential target for the OpenAI API key.
WindowsCredentialHelper¶
Provides static methods for securely storing, retrieving, updating, deleting, and listing credentials using the Windows Credential Manager via P/Invoke. No third-party dependencies.
Methods¶
DeleteCredential(string target)¶
Deletes a generic credential from Windows Credential Manager.
Parameters
target— The credential target identifier to delete.
Exceptions
System.ArgumentNullException— Thrown whentargetis null or whitespace.System.InvalidOperationException— Thrown whenCredDeletefails for a reason other than "not found".
GetCredential(string target)¶
Retrieves a generic credential from Windows Credential Manager.
Parameters
target— The credential target identifier to resolve.
Returns: The stored secret if the credential exists; otherwise .
Exceptions
System.ArgumentNullException— Thrown whentargetis null or whitespace.
ListCredentials(string filter)¶
Lists all generic credentials in Windows Credential Manager matching an optional filter.
Parameters
filter— Optional wildcard filter passed toCredEnumerate. When , all generic credentials are returned.
Returns: List of matching credential target names (may be empty).
SaveCredential(string target, string secret, string userName, string comment)¶
Saves or updates a generic credential in Windows Credential Manager.
Parameters
target— The credential target identifier (for example,smrt-hub/api).secret— The UTF-16 secret to persist. Secrets larger than 512 bytes are stored as a chunked credential set.userName— Optional user name metadata to store with the credential.comment— Optional comment metadata recorded with the credential.
Exceptions
System.ArgumentNullException— Thrown whentargetorsecretis null or whitespace.System.InvalidOperationException— Throws when the underlyingCredWritecall fails; exposes the Win32 error code.
TestUtility()¶
Test utility: save, retrieve, list, and delete a credential to validate local environment wiring.
Remarks
Built for developer diagnostics only. Calls are omitted from release builds via the DEBUG compilation symbol.
UpdateCredential(string target, string secret, string userName, string comment)¶
Updates a credential (same as save: will overwrite if exists).
Parameters
target— The credential target identifier to update.secret— The UTF-16 secret to persist.userName— Optional user name metadata to store with the credential.comment— Optional comment metadata recorded with the credential.