CrayonGroup / CloudiQ.PowerShell

A PowerShell module for managing Cloud-iQ, to help automate licensing and reporting.
https://crayongroup.github.io/CloudiQ.PowerShell/
GNU General Public License v3.0
4 stars 0 forks source link

Issues working with SecureString, cross-platform #9

Closed roberthstrand closed 3 years ago

roberthstrand commented 3 years ago

When asking for a password from the user, we use the Read-Host -AsSecureString to have the password hidden while typing. Before getting the authentication token from Cloud-iQ, we need to convert this to plain text before adding it to the header.

However, at first we had issues with Windows PowerShell since it doesn't like ConvertFrom-SecureString so we tried setting it up using the Marshal class from dotnet. Now that seems to be a problem for running the code in Azure Functions.

On reflection, decoding the string before adding it to the header means that one have to encode it first. If we didn't encode the string when using a value from $ENV:CloudiQPassword, and kept decoding to only happen if the password came from user input, we could avoid unnecessary steps.