Пример #1
0
        public static string GetPassword(string profile)
        {
            string PromptForPassword()
            {
                Logger.Info($"Enter password for {profile} parameters:");
                return(ConsoleUtility.ReadSecret());
            }

            var credentialStoreName = Constants.GetCredentialStoreName(NukeBuild.RootDirectory, profile);

            return(TryGetPasswordFromCredentialStore(credentialStoreName) ??
                   EnvironmentInfo.GetParameter <string>(Constants.GetProfilePasswordEnvironmentVariableName(profile)) ??
                   PromptForPassword());
        }
        public static string GetPassword(string profile)
        {
            string PromptForPassword()
            {
                Host.Information($"Enter password for {Constants.GetParametersFileName(profile)}:");
                return(ConsoleUtility.ReadSecret());
            }

            var credentialStoreName   = Constants.GetCredentialStoreName(NukeBuild.RootDirectory, profile);
            var passwordParameterName = Constants.GetProfilePasswordParameterName(profile);

            return(TryGetPasswordFromCredentialStore(credentialStoreName) ??
                   EnvironmentInfo.GetParameter <string>(passwordParameterName) ??
                   PromptForPassword());
        }
        public static string CreateNewPassword(out bool generated)
        {
            while (true)
            {
                Host.Information(
                    EnvironmentInfo.IsOsx
                        ? "Enter a minimum 10 character password (leave empty for auto-generated stored in macOS keychain):"
                        : "Enter a minimum 10 character password:");

                var password = ConsoleUtility.ReadSecret();
                if (password.IsNullOrEmpty() && EnvironmentInfo.IsOsx)
                {
                    generated = true;
                    return(GetGeneratedPassword(bits: 256));
                }

                if (!password.IsNullOrEmpty() && password.Length >= 10)
                {
                    generated = false;
                    return(password);
                }
            }
        }