-
Notifications
You must be signed in to change notification settings - Fork 60
Windows - Secret vault DSC resources #1496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mimachniak
wants to merge
4
commits into
PowerShell:main
Choose a base branch
from
mimachniak:secretVault-resources
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
98d1c11
Sync last barnach
mimachniak e07f69e
Merge branch 'PowerShell:main' into secretVault-resources
mimachniak a536775
Add Windows Secret Store DSC resources
mimachniak 7e1277d
Merge branch 'secretVault-resources' of https://github.com/mimachniak…
mimachniak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| [package] | ||
| name = "secret_store" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [package.metadata.i18n] | ||
| available-locales = ["en-us"] | ||
| default-locale = "en-us" | ||
| load-path = "locales" | ||
|
|
||
| [[bin]] | ||
| name = "secret_store" | ||
| path = "src/main.rs" | ||
|
|
||
| [dependencies] | ||
| rust-i18n = { workspace = true } | ||
| serde = { workspace = true } | ||
| serde_json = { workspace = true } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| _version = 1 | ||
|
|
||
| [main] | ||
| missingOperation = "Missing operation. Usage: secret_store <get|set|test|export> <vault-config|secret> [--input <json>]" | ||
| unknownOperation = "Unknown operation: '%{operation}'. Expected: get, set, test, or export" | ||
| unknownResourceType = "Unknown resource type: '%{resource_type}'. Expected: vault-config or secret" | ||
| missingArguments = "Missing required arguments. Expected: secret_store <operation> <resource-type>" | ||
| missingInput = "Missing --input argument" | ||
| missingInputValue = "Missing value for --input argument" | ||
| invalidJson = "Invalid JSON input: %{error}" | ||
| windowsOnly = "This resource is only supported on Windows" | ||
| stdinReadError = "Failed to read from stdin: %{error}" | ||
|
|
||
| [vault_config] | ||
| pwshNotFound = "PowerShell (pwsh) not found. Ensure PowerShell 7+ is installed and on the PATH." | ||
| moduleNotInstalled = "Required PowerShell module '%{module}' is not installed. Install it with: Install-Module -Name %{module} -Force" | ||
| getConfigFailed = "Failed to get SecretStore configuration: %{error}" | ||
| setConfigFailed = "Failed to set SecretStore configuration: %{error}" | ||
| unlockFailed = "Failed to unlock SecretStore: %{error}" | ||
| registerVaultFailed = "Failed to register SecretStore vault: %{error}" | ||
|
|
||
| [secret] | ||
| nameRequired = "'name' is required" | ||
| getFailed = "Failed to get secret '%{name}': %{error}" | ||
| setFailed = "Failed to set secret '%{name}': %{error}" | ||
| removeFailed = "Failed to remove secret '%{name}': %{error}" | ||
| exportFailed = "Failed to export secrets: %{error}" |
101 changes: 101 additions & 0 deletions
101
resources/secret_store/secretstoresecret.dsc.resource.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| { | ||
| "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json", | ||
| "description": "Manage individual secrets in the Microsoft.PowerShell.SecretStore vault, including creating, updating, removing, and exporting secrets.", | ||
| "tags": [ | ||
| "windows", | ||
| "secretstore", | ||
| "secretmanagement", | ||
| "secret", | ||
| "credential" | ||
| ], | ||
| "type": "Microsoft.Windows/SecretStoreSecret", | ||
| "version": "0.1.0", | ||
| "get": { | ||
| "executable": "secret_store", | ||
| "args": [ | ||
| "get", | ||
| "secret" | ||
| ], | ||
| "input": "stdin" | ||
| }, | ||
| "set": { | ||
| "executable": "secret_store", | ||
| "args": [ | ||
| "set", | ||
| "secret" | ||
| ], | ||
| "input": "stdin", | ||
| "implementsPretest": false, | ||
| "return": "state" | ||
| }, | ||
| "export": { | ||
| "executable": "secret_store", | ||
| "args": [ | ||
| "export", | ||
| "secret" | ||
| ], | ||
| "input": "stdin" | ||
| }, | ||
| "exitCodes": { | ||
| "0": "Success", | ||
| "1": "Invalid arguments", | ||
| "2": "Invalid input", | ||
| "3": "Operation error" | ||
| }, | ||
| "schema": { | ||
| "embedded": { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/resources/Microsoft.Windows/SecretStoreSecret/v0.1.0/schema.json", | ||
| "title": "SecretStore Secret", | ||
| "description": "Manages individual secrets in the Microsoft.PowerShell.SecretStore vault on Windows. Supports creating, updating, removing, and exporting secrets with optional metadata.", | ||
| "type": "object", | ||
| "required": [ | ||
| "name" | ||
| ], | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "name": { | ||
| "type": "string", | ||
| "title": "Secret name", | ||
| "description": "The name of the secret. Required for get and set operations. For export, this is optional and wildcards (*) are supported." | ||
| }, | ||
| "secretType": { | ||
| "type": "string", | ||
| "title": "Secret type", | ||
| "description": "The type of the secret. Read-only; returned by get and export operations.", | ||
| "enum": [ | ||
| "String", | ||
| "SecureString", | ||
| "ByteArray", | ||
| "PSCredential", | ||
| "Hashtable" | ||
| ], | ||
| "readOnly": true | ||
| }, | ||
| "value": { | ||
| "type": "string", | ||
| "title": "Secret value", | ||
| "description": "The value to set for the secret. Used only during set operations. Never returned by get or export." | ||
| }, | ||
| "vaultName": { | ||
| "type": "string", | ||
| "title": "Vault name", | ||
| "description": "The name of the vault to use. Defaults to the SecretStore default vault if not specified." | ||
| }, | ||
| "metadata": { | ||
| "type": "object", | ||
| "title": "Metadata", | ||
| "description": "Key-value metadata associated with the secret.", | ||
| "additionalProperties": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "_exist": { | ||
| "type": "boolean", | ||
| "title": "Exists", | ||
| "description": "Indicates whether the secret exists or should exist. Set to false to remove a secret." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
106 changes: 106 additions & 0 deletions
106
resources/secret_store/secretstorevaultconfig.dsc.resource.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| { | ||
| "$schema": "https://aka.ms/dsc/schemas/v3/bundled/resource/manifest.json", | ||
| "description": "Manage the Microsoft.PowerShell.SecretStore vault configuration, including module installation, vault registration, authentication, password timeout, and interaction settings.", | ||
| "tags": [ | ||
| "windows", | ||
| "secretstore", | ||
| "secretmanagement", | ||
| "vault", | ||
| "configuration" | ||
| ], | ||
| "type": "Microsoft.Windows/SecretStoreVaultConfig", | ||
| "version": "0.1.0", | ||
| "get": { | ||
| "executable": "secret_store", | ||
| "args": [ | ||
| "get", | ||
| "vault-config" | ||
| ], | ||
| "input": "stdin" | ||
| }, | ||
| "set": { | ||
| "executable": "secret_store", | ||
| "args": [ | ||
| "set", | ||
| "vault-config" | ||
| ], | ||
| "input": "stdin", | ||
| "implementsPretest": false, | ||
| "return": "state" | ||
| }, | ||
| "test": { | ||
| "executable": "secret_store", | ||
| "args": [ | ||
| "test", | ||
| "vault-config" | ||
| ], | ||
| "input": "stdin" | ||
| }, | ||
| "exitCodes": { | ||
| "0": "Success", | ||
| "1": "Invalid arguments", | ||
| "2": "Invalid input", | ||
| "3": "Operation error" | ||
| }, | ||
| "schema": { | ||
| "embedded": { | ||
| "$schema": "http://json-schema.org/draft-07/schema#", | ||
| "$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/resources/Microsoft.Windows/SecretStoreVaultConfig/v0.1.0/schema.json", | ||
| "title": "SecretStore Vault Configuration", | ||
| "description": "Manages the Microsoft.PowerShell.SecretStore vault configuration on Windows. Ensures modules are installed, vault is registered, and configuration (authentication, password timeout, interaction) matches desired state.", | ||
| "type": "object", | ||
| "additionalProperties": false, | ||
| "properties": { | ||
| "authentication": { | ||
| "type": "string", | ||
| "title": "Authentication type", | ||
| "description": "The authentication type for the SecretStore vault. 'Password' requires a password to unlock the vault. 'None' allows passwordless access.", | ||
| "enum": [ | ||
| "None", | ||
| "Password" | ||
| ], | ||
| "default": "Password" | ||
| }, | ||
| "passwordTimeout": { | ||
| "type": "integer", | ||
| "title": "Password timeout (seconds)", | ||
| "description": "The number of seconds the vault remains unlocked after a password is provided. After this period, the vault is automatically locked. Set to -1 for no timeout.", | ||
| "default": 900 | ||
| }, | ||
| "interaction": { | ||
| "type": "string", | ||
| "title": "Interaction preference", | ||
| "description": "Controls whether the SecretStore prompts the user. 'Prompt' allows interactive prompts. 'None' suppresses all prompts (required for automation/DSC).", | ||
| "enum": [ | ||
| "Prompt", | ||
| "None" | ||
| ], | ||
| "default": "None" | ||
| }, | ||
| "secretManagementInstalled": { | ||
| "type": "boolean", | ||
| "title": "SecretManagement module installed", | ||
| "description": "Indicates whether the Microsoft.PowerShell.SecretManagement module is installed. Read-only; returned by get operations.", | ||
| "readOnly": true | ||
| }, | ||
| "secretStoreInstalled": { | ||
| "type": "boolean", | ||
| "title": "SecretStore module installed", | ||
| "description": "Indicates whether the Microsoft.PowerShell.SecretStore module is installed. Read-only; returned by get operations.", | ||
| "readOnly": true | ||
| }, | ||
| "vaultRegistered": { | ||
| "type": "boolean", | ||
| "title": "Vault registered", | ||
| "description": "Indicates whether the SecretStore vault is registered with SecretManagement. Read-only; returned by get operations.", | ||
| "readOnly": true | ||
| }, | ||
| "_exist": { | ||
| "type": "boolean", | ||
| "title": "Exists", | ||
| "description": "Indicates whether the SecretStore configuration exists on the system (modules installed and configured)." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The embedded schema marks
nameas required, but the schema description saysnameis optional for export (wildcards supported) and the implementation also supports export with no input. Havingrequired: ["name"]can cause schema-based validation to reject valid export scenarios (e.g. an empty filter object). Consider removing the top-levelrequiredconstraint and enforcingnameat runtime only for get/set operations (as the code already does).