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
PowerShell Core editions cannot properly run deploy_stack.ps1 #1475
Comments
Thanks for bringing this up! There are no real password requirements as far as OpenFaaS is concerned. In the I'm fairly certain there is a function (or commandlet) in PowerShell that is similar to the one used in our bash scripts: secret=$(head -c 16 /dev/urandom| $sha_cmd | cut -d " " -f 1) |
In that case, I put together this function that should mimic what the snippet is doing in the bash script. function generatePassword {
$b = [byte[]](1..16)
(new-object Security.Cryptography.RNGCryptoServiceProvider).GetBytes($b)
$string = [Text.encoding]::UTF8.GetBytes( -join ($b | ForEach-Object { [char[]](65..90 + 57..33)[$_%51] }))
$hmacsha = New-Object System.Security.Cryptography.HMACSHA256
$hash = $hmacsha.ComputeHash([Text.Encoding]::ASCII.GetBytes($string))
$password = ([System.BitConverter]::ToString($hash) -replace '-', '').ToLower()
return $password
} A sample output would be: I have tested the function on these PowerShell versions:
What are your thoughts? |
I like it! It's great that it works across the versions and is self-contained within the script. I'm surprised it's as complex as it is, but it does work (just tested on my Windows 5.1). I'd be happy with this in a PR. Thanks! 💯 |
Yes, it is a little longer than the bash version but I can't seem to find a way around it. in Thank you for the feedback. I will submit a PR. |
Okay, now that I am putting the new code into the actual $password = -join ((33..126) * 120 | Get-Random -Count 24 | ForEach-Object { [char]$_ })
$secret = "" |
I would say that I prefer the |
@alexellis I agree, |
The powershell script has been removed, please use arkade instead, or helm and Git Bash. |
/lock: resolved |
My actions before raising this issue
Currently, .NET Core does not support System.Web.dll which causes
[System.Web.Security.Membership]::GeneratePassword(14, 5)
to fail.When running the script with a
Core
edition of PowerShell such as6.0.0
or7.0.0
the script runs but fails to generate a password. The script continues to completion with no way to access the UI or CLI since the password is unknown/no-set.Expected Behaviour
It is expected that when running
deploy_stack.ps1
inany
version of PowerShell that the script will run successfully.Current Behaviour
In this case, PowerShell Core cannot use the
system.web.security
assembly, therefore, cannot run$password = [System.Web.Security.Membership]::GeneratePassword(24,5)
.The script runs through until completion but does not successfully set the password to be used.
Here is the output of the script running in
7.0.0
.Possible Solution
The
best
solution is to determine an alternate method to generate (securely) a random password without requiringsystem.web.dll
do to lack of support forCore
PowerShell editions.A temporary solution would be to add
#Requires -PSEdition Desktop
to at least notify the end-user that using aCore
version of PowerShell will not work. It currentlyappears
to complete but there is no way to log in.Steps to Reproduce (for bugs)
PowerShell Core
(6.0.0
,7.0.0
, etc.)deploy_stack.ps1
(using default parameters)Context
Simply trying to run default installation/deployment of OpenFaas via Docker Swarm.
Your Environment
faas-cli version
): 0.1.6Docker version
docker version
(e.g. Docker 17.0.05 ): 19.03.5Are you using Docker Swarm or Kubernetes (FaaS-netes)? Swarm
Operating System and version (e.g. Linux, Windows, MacOS): Windows
Code example or link to GitHub repo or gist to reproduce problem:
./deploy_stack.ps1
Other diagnostic information / logs from troubleshooting guide
Next steps
You may join Slack for community support.
The text was updated successfully, but these errors were encountered: