Title: [SecretManagement] Get-Secret / Set-Secret hooks support · Issue #94 · PowerShell/Modules · GitHub
Open Graph Title: [SecretManagement] Get-Secret / Set-Secret hooks support · Issue #94 · PowerShell/Modules
X Title: [SecretManagement] Get-Secret / Set-Secret hooks support · Issue #94 · PowerShell/Modules
Description: Additional optional vault parameters to support hooks : After a secret is received, before it is returned to the user Before a secret is set and sent to the keyvault. The Flow of operations would be : Get-Secret is called AfterGet script...
Open Graph Description: Additional optional vault parameters to support hooks : After a secret is received, before it is returned to the user Before a secret is set and sent to the keyvault. The Flow of operations would b...
X Description: Additional optional vault parameters to support hooks : After a secret is received, before it is returned to the user Before a secret is set and sent to the keyvault. The Flow of operations would b...
Opengraph URL: https://github.com/PowerShell/Modules/issues/94
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[SecretManagement] Get-Secret / Set-Secret hooks support","articleBody":"# Additional optional vault parameters to support hooks : \r\n- After a secret is received, before it is returned to the user\r\n- Before a secret is set and sent to the keyvault. \r\n\r\nThe Flow of operations would be : \r\n\r\n- Get-Secret is called\r\n- AfterGet scriptblock is invoked (if present in vault registration)\r\n- Secret is returned\r\n\r\n- Set-Secret is called\r\n- BeforeSet scriptblock is invoked (if present in vault registration)\r\n- Secret is set in the SecretVault\r\n\r\nThe idea is to overhaul existing providers with additional features without creating a custom implementation and / or having to use a second function to pre-process / post-process a secret before using the Get/Set secret. \r\n\r\n\r\n**Some potential uses**\r\n- Double encryption before sending a credential into an external vault (eg: ProtectTo-Cms)\r\n- Managing incomplete implementation (eg: Az.Keyvault support only SecureString. You could use a hook on the BeforeSet to convert the other supported types (hashtable, pscredential, etc) to secure string and the AfterGet to convert it back )\r\n- Accepting custom secret classes (by using BeforeSet to convert the unsupported type to something else and back again to the class in the AfterGet) \r\n\r\n**Main advantage**\r\nThe main benefit of having those options as scriptblock defined in the vault registration is that it is would be embedded into that vault, meaning if you want to use Protect-CMS before sending your secret into the vault, you'd have to do it manually and every time. Furthermore, you'd have to to the reverse operation every time after getting your secret back.\r\n\r\nThe idea of hook streamline that process by embedding further capabilities directly into Get-Secret / Set-Secret managed directly and transparently through the vault registration.\r\n\r\n\r\n\r\nExample 1 : Double encryption \r\n```Powershell\r\n$Params = @{\r\n 'AffterGet' = { $_ | Unprotect-CmsMessage \"*youralias@emailaddress.com*\" }\r\n 'BeforeSet' = { $_ | Protect-CmsMessage -To \"*youralias@emailaddress.com*\" }\r\n}\r\n\r\nRegister-SecretVault -Name 'DoubleEncryptionVault' -VaultParameters $params\r\n```\r\n\r\nExample 2 : \r\nI opened these issues regarding Az.Keyvault implementation, which only support SecureString.\r\nWith hooks, I could easily had registered my vault with Scriptblock to manage conversion from other supported type to SecureString before Set-Secret set the actual secret in the vault and back from the SecureString to the desired type. It would have allowed me to workaround the Az.Keyvault limitation, which might or might not be fixed anytime soon.\r\n\r\nhttps://github.com/PowerShell/Modules/issues/93\r\nhttps://github.com/Azure/azure-powershell/issues/12190\r\n\r\n\r\nExample 3: \r\nThis ultimately will fail.\r\nPSCustomObject and classes are not supported.\r\nHowever, with hooks, I could manage the conversion of the unknown object to something manageable by the Set-Secret accepted type and even enforce specific types.\r\n\r\n```Powershell\r\n$CustomObject = [PSCustomObject]@{\r\n 'Hello' = 'World'\r\n 'Foo' = 'Bar'\r\n}\r\n\r\n\r\n$CustomObject.GetType()\r\n\r\nSet-Secret -Vault BuiltInLocalVault -Name test -Secret $CustomObject\r\n```\r\n","author":{"url":"https://github.com/itfranck","@type":"Person","name":"itfranck"},"datePublished":"2020-06-17T09:44:08Z","url":"https://github.com/PowerShell/Modules/issues/94"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:0483f1be-e08e-8ea5-abb5-0d8a8509343f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8652:27BEFF:9AD214:D4DB97:6AFD35E0 |
| html-safe-nonce | a4ce1005cc74cd1439516ee4e0075711262c7329b264bdf9224e8ea3ba5374f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NjUyOjI3QkVGRjo5QUQyMTQ6RDREQjk3OjZBRkQzNUUwIiwidmlzaXRvcl9pZCI6IjU5MjUwNzI5MjMyNTY1MDE3MjgiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | c51af9c0aef00a0b904e03811f42dfb9e629a2ae23c36ac044f963874ca4ecee |
| hovercard-subject-tag | issue:640299762 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/Modules/94/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8b397d8225e9f3ad8cc042af8a7bf89d893a188e7be0e9846dfe2b2466090445/PowerShell/Modules/issues/94 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8b397d8225e9f3ad8cc042af8a7bf89d893a188e7be0e9846dfe2b2466090445/PowerShell/Modules/issues/94 |
| og:image:alt | Additional optional vault parameters to support hooks : After a secret is received, before it is returned to the user Before a secret is set and sent to the keyvault. The Flow of operations would b... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | itfranck |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/Modules git https://github.com/PowerShell/Modules.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 197814114 |
| octolytics-dimension-repository_nwo | PowerShell/Modules |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 197814114 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/Modules |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width