{"id":19026,"date":"2021-05-25T10:30:36","date_gmt":"2021-05-25T18:30:36","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/powershell\/?p=19026"},"modified":"2022-04-06T09:52:53","modified_gmt":"2022-04-06T17:52:53","slug":"secretmanagement-module-v1-1-0-preview-update","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/secretmanagement-module-v1-1-0-preview-update\/","title":{"rendered":"SecretManagement Module v1.1.0 preview update"},"content":{"rendered":"<h2>Microsoft.PowerShell.SecretManagement 1.1.0-preview<\/h2>\n<p>The next 1.1.0 version of SecretManagement has a number of minor fixes, but also two significant changes, one of which is a potentially breaking change for extension authors.\nFor more information on the changes in this release, see the <a href=\"https:\/\/github.com\/PowerShell\/SecretManagement\/blob\/master\/CHANGELOG.md\">CHANGELOG document<\/a>.\nThis blog discusses the primary changes, why one is potentially breaking, and is especially relevant for extension vault owners who may want to test their vault and make any changes while these updates are in a preview state.  <\/p>\n<h2>SecretManagement extension vault modules hosting change<\/h2>\n<p>SecretManagement extension vaults are PowerShell modules that conform to a special format.\nCurrently, when SecretManagement loads an extension vault module for use, it loads the module into the current user session.\nHowever, this method of hosting extension vault modules prevented SecretManagement from running in ConstrainedLanguage (CL) mode.\nTo fix this problem, v1.1.0 of SecretManagement now hosts extension vaults in a separate runspace session.\nChanging how the extension module is hosted, has the potential to break existing extension vaults.  <\/p>\n<h3>What are the effects of the hosting change?<\/h3>\n<p>This change mostly affects extension vault authors because they can no longer assume their loaded vault module has access to current user session state.\nGenerally, extension vaults should never rely on shared user session state.\nBut if an extension did have this dependency, it would no longer work with this next version of SecretManagement.\nWe tested some extension vault modules on the <a href=\"https:\/\/www.powershellgallery.com\/packages?q=SecretManagement\">PowerShellGallery<\/a>, but found only one module that was affected by this change (SecretManagement.KeePass).  <\/p>\n<h3>SecretManagement.KeePass extension vault<\/h3>\n<p>The <a href=\"https:\/\/www.powershellgallery.com\/packages\/SecretManagement.KeePass\">SecretManagement.KeePass<\/a> extension vault currently relies on its module being loaded in the user session in order to support its vault unlock operation via the <code>Unlock-KeePassSecretVault<\/code> command.\nWith the new SecretManagement version, the <code>Unlock-KeePassSecretVault<\/code> cmdlet is no longer effective, and the user is always prompted for a password when required by the vault.\nThis can be problematic for scripts being run unattended that do not support user interaction.  <\/p>\n<p>The KeePass vault needed to use this user shared state approach due to a deficiency in SecretManagement.\nSecretManagement did not support a vault unlock operation, and required vaults that needed it to implement their own.\nSo one of the changes in this release is to add a new extension vault function, <code>Unlock-SecretVault<\/code>, that allows extension vaults to provide this functionality directly through SecretManagement.\nWith this new function, the KeePass vault no longer needs to leverage shared state with the user session.  <\/p>\n<h3>New Unlock-SecretVault command<\/h3>\n<p>SecretManagement now supports a new <code>Unlock-SecretVault<\/code> command.\nExtension vaults that require unlocking can optionally support this by implementing the <code>Unlock-SecretVault<\/code> function in their extension.\nSecretManagement.KeePass extension vault module will be updated to use this new function, mitigating the problem.\nFor more information see SecretManagement <a href=\"https:\/\/github.com\/powershell\/secretmanagement#readme\">Readme<\/a> and <a href=\"https:\/\/github.com\/PowerShell\/SecretManagement\/blob\/master\/Docs\/ARCHITECTURE.md\">Design<\/a> documentation.  <\/p>\n<h3>Other differences you may notice<\/h3>\n<p>Since the extension vaults are no longer loaded in the user session, you will no longer see them listed when you run the <code>Get-Module<\/code> command, which lists the currently loaded modules in your session.\nThis is arguably a good thing, since users generally don&#8217;t want or need to know about extension vault modules, and don&#8217;t need to see them in their current session.\nSeeing extension vault modules unexpectedly loaded in their sessions may be confusing to users.  <\/p>\n<p>Some extension vault modules, such as <a href=\"https:\/\/www.powershellgallery.com\/packages\/Microsoft.PowerShell.SecretManagement\">Microsoft.PowerShell.SecretStore<\/a> and <a href=\"https:\/\/www.powershellgallery.com\/packages\/SecretManagement.KeePass\">SecretManagement.KeePass<\/a>, include additional commands for the user.\nThe Microsoft.PowerShell.SecretStore vault provides additional commands for configuring the vault.\nThe SecretManagement.KeepPass vault provides additional commands for unlocking and registering the vault.\nThese commands will continue to work.\nWhen these commands are run, the extension vault module will be visible from <code>Get-Module<\/code> because the commands are run in the current user session.\nBut that is the only time the extension vault modules will be loaded in the user session.  <\/p>\n<h3>What is a runspace?<\/h3>\n<p>A PowerShell runspace encompasses the session context in which PowerShell scripts run, and can be thought of as an individual PowerShell session.\nThe PowerShell command shell usually has just a single session, but can support any number of sessions via multiple runspaces.\nThe runspace isolates multiple running scripts from each other within a single process.  <\/p>\n<h3>What is CL mode?<\/h3>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/powershell\/powershell-constrained-language-mode\/\">Constrained Language<\/a> is a PowerShell language mode that restricts language elements which can be used to invoke arbitrary APIs.\nIt is commonly used within a system wide application control policy, such as Windows AppLocker or Windows Defender Application Control, that restricts what applications are available and what scripts are trusted on the system.\nUntrusted scripts run in ConstrainedLanguage while trusted scripts run in FullLanguage mode.  <\/p>\n<h2>Feedback and Support<\/h2>\n<p>Community feedback has been essential to the iterative development of these modules.\nThank you to everyone who has contributed issues, and feedback thus far!\nTo file issues or get support for the SecretManagement interface or vault development experience please use the <a href=\"https:\/\/github.com\/PowerShell\/SecretManagement\">SecretManagement<\/a> repository.\nFor issues which pertain specifically to the SecretStore and its cmdlet interface please use the <a href=\"https:\/\/github.com\/PowerShell\/SecretStore\">SecretStore<\/a> repository.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Potential breaking change in the latest preview of SecretManagement 1.1 module release<\/p>\n","protected":false},"author":7325,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3174],"class_list":["post-19026","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-secretmanagement"],"acf":[],"blog_post_summary":"<p>Potential breaking change in the latest preview of SecretManagement 1.1 module release<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19026","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/7325"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=19026"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/19026\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=19026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=19026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=19026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}