Skip to content

Commit 0f61f25

Browse files
committed
!deploy v2.36.2 with logic fixes
## 2.36.2 - 2020-03-02 * [Issue #263](#263) * Cleaned up decryption logic for encrypted config.
1 parent 4a5582e commit 0f61f25

7 files changed

+83
-117
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
* [PSGSuite - ChangeLog](#psgsuite---changelog)
2+
* [2.36.2 - 2020-03-02](#2362---2020-03-02)
23
* [2.36.1 - 2020-03-02](#2361---2020-03-02)
34
* [2.36.0 - 2020-02-28](#2360---2020-02-28)
45
* [2.35.1 - 2019-12-29](#2351---2019-12-29)
@@ -108,6 +109,11 @@
108109

109110
# PSGSuite - ChangeLog
110111

112+
## 2.36.2 - 2020-03-02
113+
114+
* [Issue #263](https://github.com/scrthq/PSGSuite/issues/263)
115+
* Cleaned up decryption logic for encrypted config.
116+
111117
## 2.36.1 - 2020-03-02
112118

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

PSGSuite/PSGSuite.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'PSGSuite.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.36.1'
15+
ModuleVersion = '2.36.2'
1616

1717
# ID used to uniquely identify this module
1818
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'

PSGSuite/Private/EncryptionHelpers.ps1

+63
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
1+
function Get-GSDecryptedConfig {
2+
[CmdletBinding()]
3+
Param(
4+
[parameter(Position = 0,ValueFromPipeline,Mandatory)]
5+
[object]
6+
$Config,
7+
[parameter(Position = 1,Mandatory)]
8+
[string]
9+
$ConfigName,
10+
[parameter(Position = 2)]
11+
[string]
12+
$ConfigPath
13+
)
14+
Process {
15+
$Config | Select-Object -Property `
16+
@{l = 'ConfigName';e = { $ConfigName }},
17+
@{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } },
18+
'P12Key',
19+
@{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } },
20+
@{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } },
21+
@{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } },
22+
@{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } },
23+
@{l = 'AppEmail'; e = {
24+
if ($_.AppEmail) {
25+
Invoke-GSDecrypt $_.AppEmail
26+
}
27+
elseif ($_.ClientSecrets) {
28+
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email
29+
}
30+
}
31+
},
32+
@{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } },
33+
@{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } },
34+
@{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } },
35+
@{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } },
36+
@{l = 'ServiceAccountClientID'; e = {
37+
if ($_.ServiceAccountClientID) {
38+
Invoke-GSDecrypt $_.ServiceAccountClientID
39+
}
40+
elseif ($_.ClientSecrets) {
41+
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id
42+
}
43+
}
44+
},
45+
@{l = 'Chat'; e = {
46+
$dict = @{
47+
Webhooks = @{ }
48+
Spaces = @{ }
49+
}
50+
foreach ($key in $_.Chat.Webhooks.Keys) {
51+
$dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key])
52+
}
53+
foreach ($key in $_.Chat.Spaces.Keys) {
54+
$dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key])
55+
}
56+
$dict
57+
}
58+
},
59+
@{l = 'ConfigPath'; e = {
60+
if ($ConfigPath) {(Resolve-Path $ConfigPath).Path} elseif ($_.ConfigPath) {$_.ConfigPath} else {$null}
61+
}}
62+
}
63+
}
164
function Invoke-GSDecrypt {
265
param($String)
366
if ($String -is [System.Security.SecureString]) {

PSGSuite/Public/Configuration/Get-PSGSuiteConfig.ps1

+7-57
Original file line numberDiff line numberDiff line change
@@ -77,63 +77,13 @@ function Get-PSGSuiteConfig {
7777
}
7878
}
7979
}
80-
$decryptedConfig = $encConf | Select-Object -Property @{l = 'ConfigName';e = { $choice }},
81-
@{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } },
82-
'P12Key',
83-
@{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } },
84-
@{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } },
85-
@{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } },
86-
@{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } },
87-
@{l = 'AppEmail'; e = {
88-
if ($_.AppEmail) {
89-
Invoke-GSDecrypt $_.AppEmail
90-
}
91-
elseif ($_.ClientSecrets) {
92-
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email
93-
}
94-
}
95-
},
96-
@{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } },
97-
@{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } },
98-
@{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } },
99-
@{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } },
100-
@{l = 'ServiceAccountClientID'; e = {
101-
if ($_.ServiceAccountClientID) {
102-
Invoke-GSDecrypt $_.ServiceAccountClientID
103-
}
104-
elseif ($_.ClientSecrets) {
105-
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id
106-
}
107-
}
108-
},
109-
@{l = 'Chat'; e = {
110-
$dict = @{
111-
Webhooks = @{ }
112-
Spaces = @{ }
113-
}
114-
foreach ($key in $_.Chat.Webhooks.Keys) {
115-
$dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key])
116-
}
117-
foreach ($key in $_.Chat.Spaces.Keys) {
118-
$dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key])
119-
}
120-
$dict
121-
}
122-
},
123-
@{
124-
l = 'ConfigPath'
125-
e = {
126-
if ($_.ConfigPath) {
127-
$_.ConfigPath
128-
}
129-
elseif ($Path) {
130-
(Resolve-Path $Path).Path
131-
}
132-
else {
133-
$null
134-
}
135-
}
136-
}
80+
$decryptParams = @{
81+
ConfigName = $choice
82+
}
83+
if ($Path) {
84+
$decryptParams['ConfigPath'] = $Path
85+
}
86+
$decryptedConfig = $encConf | Get-GSDecryptedConfig @decryptParams
13787
Write-Verbose "Retrieved configuration '$choice'"
13888
if (!$NoImport) {
13989
$script:PSGSuite = $decryptedConfig

PSGSuite/Public/Configuration/Set-PSGSuiteConfig.ps1

-14
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,6 @@ function Set-PSGSuiteConfig {
142142
[switch]
143143
$NoImport
144144
)
145-
Begin {
146-
Function Invoke-GSEncrypt {
147-
param($string)
148-
if ($string -is [System.Security.SecureString]) {
149-
$string
150-
}
151-
elseif ($string -is [System.String] -and $String -notlike '') {
152-
ConvertTo-SecureString -String $string -AsPlainText -Force
153-
}
154-
elseif ($string -is [System.Management.Automation.ScriptBlock]) {
155-
$string
156-
}
157-
}
158-
}
159145
Process {
160146
$script:ConfigScope = $Scope
161147
$configHash = Import-SpecificConfiguration -CompanyName 'SCRT HQ' -Name 'PSGSuite'

PSGSuite/Public/Configuration/Switch-PSGSuiteConfig.ps1

+1-45
Original file line numberDiff line numberDiff line change
@@ -74,51 +74,7 @@
7474
}
7575
}
7676
if ($choice) {
77-
$script:PSGSuite = [PSCustomObject]($fullConf[$choice]) |
78-
Select-Object -Property @{l = 'ConfigName';e = { $choice }},
79-
@{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } },
80-
'P12Key',
81-
@{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } },
82-
@{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } },
83-
@{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } },
84-
@{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } },
85-
@{l = 'AppEmail'; e = {
86-
if ($_.AppEmail) {
87-
Invoke-GSDecrypt $_.AppEmail
88-
}
89-
elseif ($_.ClientSecrets) {
90-
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email
91-
}
92-
}
93-
},
94-
@{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } },
95-
@{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } },
96-
@{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } },
97-
@{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } },
98-
@{l = 'ServiceAccountClientID'; e = {
99-
if ($_.ServiceAccountClientID) {
100-
Invoke-GSDecrypt $_.ServiceAccountClientID
101-
}
102-
elseif ($_.ClientSecrets) {
103-
(Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id
104-
}
105-
}
106-
},
107-
@{l = 'Chat'; e = {
108-
$dict = @{
109-
Webhooks = @{ }
110-
Spaces = @{ }
111-
}
112-
foreach ($key in $_.Chat.Webhooks.Keys) {
113-
$dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key])
114-
}
115-
foreach ($key in $_.Chat.Spaces.Keys) {
116-
$dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key])
117-
}
118-
$dict
119-
}
120-
},
121-
ConfigPath
77+
$script:PSGSuite = [PSCustomObject]($fullConf[$choice]) | Get-GSDecryptedConfig -ConfigName $choice
12278
if ($SetToDefault) {
12379
if ($defaultConfigName -ne $choice) {
12480
Write-Verbose "Setting config name '$choice' for domain '$($script:PSGSuite.Domain)' as default"

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ All other functions are either intact or have an alias included to support backw
158158

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

161+
#### 2.36.2 - 2020-03-02
162+
163+
* [Issue #263](https://github.com/scrthq/PSGSuite/issues/263)
164+
* Cleaned up decryption logic for encrypted config.
165+
161166
#### 2.36.1 - 2020-03-02
162167

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

0 commit comments

Comments
 (0)