Skip to content

Commit

Permalink
!deploy v2.36.2 with logic fixes
Browse files Browse the repository at this point in the history
## 2.36.2 - 2020-03-02

* [Issue #263](#263)
    * Cleaned up decryption logic for encrypted config.
  • Loading branch information
scrthq committed Mar 3, 2020
1 parent 4a5582e commit 0f61f25
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 117 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* [PSGSuite - ChangeLog](#psgsuite---changelog)
* [2.36.2 - 2020-03-02](#2362---2020-03-02)
* [2.36.1 - 2020-03-02](#2361---2020-03-02)
* [2.36.0 - 2020-02-28](#2360---2020-02-28)
* [2.35.1 - 2019-12-29](#2351---2019-12-29)
Expand Down Expand Up @@ -108,6 +109,11 @@

# PSGSuite - ChangeLog

## 2.36.2 - 2020-03-02

* [Issue #263](https://github.com/scrthq/PSGSuite/issues/263)
* Cleaned up decryption logic for encrypted config.

## 2.36.1 - 2020-03-02

* [Issue #263](https://github.com/scrthq/PSGSuite/issues/263)
Expand Down
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.36.1'
ModuleVersion = '2.36.2'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
63 changes: 63 additions & 0 deletions PSGSuite/Private/EncryptionHelpers.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
function Get-GSDecryptedConfig {
[CmdletBinding()]
Param(
[parameter(Position = 0,ValueFromPipeline,Mandatory)]
[object]
$Config,
[parameter(Position = 1,Mandatory)]
[string]
$ConfigName,
[parameter(Position = 2)]
[string]
$ConfigPath
)
Process {
$Config | Select-Object -Property `
@{l = 'ConfigName';e = { $ConfigName }},
@{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } },
'P12Key',
@{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } },
@{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } },
@{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } },
@{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } },
@{l = 'AppEmail'; e = {
if ($_.AppEmail) {
Invoke-GSDecrypt $_.AppEmail
}
elseif ($_.ClientSecrets) {
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email
}
}
},
@{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } },
@{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } },
@{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } },
@{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } },
@{l = 'ServiceAccountClientID'; e = {
if ($_.ServiceAccountClientID) {
Invoke-GSDecrypt $_.ServiceAccountClientID
}
elseif ($_.ClientSecrets) {
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id
}
}
},
@{l = 'Chat'; e = {
$dict = @{
Webhooks = @{ }
Spaces = @{ }
}
foreach ($key in $_.Chat.Webhooks.Keys) {
$dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key])
}
foreach ($key in $_.Chat.Spaces.Keys) {
$dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key])
}
$dict
}
},
@{l = 'ConfigPath'; e = {
if ($ConfigPath) {(Resolve-Path $ConfigPath).Path} elseif ($_.ConfigPath) {$_.ConfigPath} else {$null}
}}
}
}
function Invoke-GSDecrypt {
param($String)
if ($String -is [System.Security.SecureString]) {
Expand Down
64 changes: 7 additions & 57 deletions PSGSuite/Public/Configuration/Get-PSGSuiteConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,63 +77,13 @@ function Get-PSGSuiteConfig {
}
}
}
$decryptedConfig = $encConf | Select-Object -Property @{l = 'ConfigName';e = { $choice }},
@{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } },
'P12Key',
@{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } },
@{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } },
@{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } },
@{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } },
@{l = 'AppEmail'; e = {
if ($_.AppEmail) {
Invoke-GSDecrypt $_.AppEmail
}
elseif ($_.ClientSecrets) {
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email
}
}
},
@{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } },
@{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } },
@{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } },
@{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } },
@{l = 'ServiceAccountClientID'; e = {
if ($_.ServiceAccountClientID) {
Invoke-GSDecrypt $_.ServiceAccountClientID
}
elseif ($_.ClientSecrets) {
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id
}
}
},
@{l = 'Chat'; e = {
$dict = @{
Webhooks = @{ }
Spaces = @{ }
}
foreach ($key in $_.Chat.Webhooks.Keys) {
$dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key])
}
foreach ($key in $_.Chat.Spaces.Keys) {
$dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key])
}
$dict
}
},
@{
l = 'ConfigPath'
e = {
if ($_.ConfigPath) {
$_.ConfigPath
}
elseif ($Path) {
(Resolve-Path $Path).Path
}
else {
$null
}
}
}
$decryptParams = @{
ConfigName = $choice
}
if ($Path) {
$decryptParams['ConfigPath'] = $Path
}
$decryptedConfig = $encConf | Get-GSDecryptedConfig @decryptParams
Write-Verbose "Retrieved configuration '$choice'"
if (!$NoImport) {
$script:PSGSuite = $decryptedConfig
Expand Down
14 changes: 0 additions & 14 deletions PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -142,20 +142,6 @@ function Set-PSGSuiteConfig {
[switch]
$NoImport
)
Begin {
Function Invoke-GSEncrypt {
param($string)
if ($string -is [System.Security.SecureString]) {
$string
}
elseif ($string -is [System.String] -and $String -notlike '') {
ConvertTo-SecureString -String $string -AsPlainText -Force
}
elseif ($string -is [System.Management.Automation.ScriptBlock]) {
$string
}
}
}
Process {
$script:ConfigScope = $Scope
$configHash = Import-SpecificConfiguration -CompanyName 'SCRT HQ' -Name 'PSGSuite'
Expand Down
46 changes: 1 addition & 45 deletions PSGSuite/Public/Configuration/Switch-PSGSuiteConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,51 +74,7 @@
}
}
if ($choice) {
$script:PSGSuite = [PSCustomObject]($fullConf[$choice]) |
Select-Object -Property @{l = 'ConfigName';e = { $choice }},
@{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } },
'P12Key',
@{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } },
@{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } },
@{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } },
@{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } },
@{l = 'AppEmail'; e = {
if ($_.AppEmail) {
Invoke-GSDecrypt $_.AppEmail
}
elseif ($_.ClientSecrets) {
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email
}
}
},
@{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } },
@{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } },
@{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } },
@{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } },
@{l = 'ServiceAccountClientID'; e = {
if ($_.ServiceAccountClientID) {
Invoke-GSDecrypt $_.ServiceAccountClientID
}
elseif ($_.ClientSecrets) {
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id
}
}
},
@{l = 'Chat'; e = {
$dict = @{
Webhooks = @{ }
Spaces = @{ }
}
foreach ($key in $_.Chat.Webhooks.Keys) {
$dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key])
}
foreach ($key in $_.Chat.Spaces.Keys) {
$dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key])
}
$dict
}
},
ConfigPath
$script:PSGSuite = [PSCustomObject]($fullConf[$choice]) | Get-GSDecryptedConfig -ConfigName $choice
if ($SetToDefault) {
if ($defaultConfigName -ne $choice) {
Write-Verbose "Setting config name '$choice' for domain '$($script:PSGSuite.Domain)' as default"
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ All other functions are either intact or have an alias included to support backw

[Full CHANGELOG here](https://github.com/scrthq/PSGSuite/blob/master/CHANGELOG.md)

#### 2.36.2 - 2020-03-02

* [Issue #263](https://github.com/scrthq/PSGSuite/issues/263)
* Cleaned up decryption logic for encrypted config.

#### 2.36.1 - 2020-03-02

* [Issue #263](https://github.com/scrthq/PSGSuite/issues/263)
Expand Down

0 comments on commit 0f61f25

Please sign in to comment.