File tree Expand file tree Collapse file tree 5 files changed +27
-9
lines changed Expand file tree Collapse file tree 5 files changed +27
-9
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ Describe "Download with RemoteScriptCall" {
1414 }
1515 New-Item - Path $destinationMediaPath - ItemType Directory | Out-Null
1616
17- $session = New-ScriptSession - Username " sitecore\admin" - Password " b" - ConnectionUri $protocolHost
17+ $sharedSecret = ' 7AF6F59C14A05786E97012F054D1FB98AC756A2E54E5C9ACBAEE147D9ED0E0DB'
18+ # $session = New-ScriptSession -Username "sitecore\admin" -Password "b" -ConnectionUri $protocolHost
19+ $session = New-ScriptSession - Username " sitecore\admin" - SharedSecret $sharedSecret - ConnectionUri $protocolHost
1820 }
1921 AfterEach {
2022 Stop-ScriptSession - Session $session
Original file line number Diff line number Diff line change @@ -11,7 +11,9 @@ if(!$protocolHost){
1111
1212Describe " Upload with RemoteScriptCall" {
1313 BeforeEach {
14- $session = New-ScriptSession - Username " sitecore\admin" - Password " b" - ConnectionUri $protocolHost
14+ $sharedSecret = ' 7AF6F59C14A05786E97012F054D1FB98AC756A2E54E5C9ACBAEE147D9ED0E0DB'
15+ # $session = New-ScriptSession -Username "sitecore\admin" -Password "b" -ConnectionUri $protocolHost
16+ $session = New-ScriptSession - Username " sitecore\admin" - SharedSecret $sharedSecret - ConnectionUri $protocolHost
1517 $localFilePath = Join-Path - Path $PSScriptRoot - ChildPath " spe-test"
1618 }
1719 AfterEach {
Original file line number Diff line number Diff line change @@ -136,6 +136,7 @@ function Receive-RemoteItem {
136136 if ($Session ) {
137137 $Username = $Session.Username
138138 $Password = $Session.Password
139+ $SharedSecret = $Session.SharedSecret
139140 $Credential = $Session.Credential
140141 $UseDefaultCredentials = $Session.UseDefaultCredentials
141142 $ConnectionUri = $Session | ForEach-Object { $_.Connection.BaseUri }
@@ -164,9 +165,15 @@ function Receive-RemoteItem {
164165 $handler = New-Object System.Net.Http.HttpClientHandler
165166 $handler.AutomaticDecompression = [System.Net.DecompressionMethods ]::GZip -bor [System.Net.DecompressionMethods ]::Deflate
166167 $client = New-Object - TypeName System.Net.Http.Httpclient $handler
167- $authBytes = [System.Text.Encoding ]::GetEncoding(" iso-8859-1" ).GetBytes(" $ ( $Username ) :$ ( $Password ) " )
168- $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue(" Basic" , [System.Convert ]::ToBase64String($authBytes ))
169-
168+
169+ if (! [string ]::IsNullOrEmpty($SharedSecret )) {
170+ $token = New-Jwt - Algorithm ' HS256' - Issuer ' SPE Remoting' - Audience ($uri.GetLeftPart ([System.UriPartial ]::Authority)) - Name $Username - SecretKey $SharedSecret - ValidforSeconds 30
171+ $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue(" Bearer" , $token )
172+ } else {
173+ $authBytes = [System.Text.Encoding ]::GetEncoding(" iso-8859-1" ).GetBytes(" $ ( $Username ) :$ ( $Password ) " )
174+ $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue(" Basic" , [System.Convert ]::ToBase64String($authBytes ))
175+ }
176+
170177 if ($Credential ) {
171178 $handler.Credentials = $Credential
172179 }
Original file line number Diff line number Diff line change 1111 RootModule = ' .\SPE.psm1'
1212
1313 # Version number of this module.
14- ModuleVersion = ' 6.2 .0'
14+ ModuleVersion = ' 6.3 .0'
1515
1616 # ID used to uniquely identify this module
1717 GUID = ' cf8d3b69-b293-4d8b-9974-e1ab80509724'
2323 CompanyName = ' Sitecore PowerShell Extensions'
2424
2525 # Copyright statement for this module
26- Copyright = ' (c) 2010-2020 Adam Najmanowicz, Michael West. All rights Reserved.'
26+ Copyright = ' (c) 2010-2021 Adam Najmanowicz, Michael West. All rights Reserved.'
2727
2828 # Description of the functionality provided by this module
2929 Description = ' The SPE Remoting module provides remote connectivity to a Sitecore instance. The Sitecore PowerShell Extensions (SPE) module must be installed and configured to accept remoting connections.'
Original file line number Diff line number Diff line change @@ -142,6 +142,7 @@ function Send-RemoteItem {
142142 if ($Session ) {
143143 $Username = $Session.Username
144144 $Password = $Session.Password
145+ $SharedSecret = $Session.SharedSecret
145146 $Credential = $Session.Credential
146147 $UseDefaultCredentials = $Session.UseDefaultCredentials
147148 $ConnectionUri = $Session | ForEach-Object { $_.Connection.BaseUri }
@@ -172,8 +173,14 @@ function Send-RemoteItem {
172173 $handler = New-Object System.Net.Http.HttpClientHandler
173174 $handler.AutomaticDecompression = [System.Net.DecompressionMethods ]::GZip -bor [System.Net.DecompressionMethods ]::Deflate
174175 $client = New-Object - TypeName System.Net.Http.Httpclient $handler
175- $authBytes = [System.Text.Encoding ]::GetEncoding(" iso-8859-1" ).GetBytes(" $ ( $Username ) :$ ( $Password ) " )
176- $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue(" Basic" , [System.Convert ]::ToBase64String($authBytes ))
176+
177+ if (! [string ]::IsNullOrEmpty($SharedSecret )) {
178+ $token = New-Jwt - Algorithm ' HS256' - Issuer ' SPE Remoting' - Audience ($uri.GetLeftPart ([System.UriPartial ]::Authority)) - Name $Username - SecretKey $SharedSecret - ValidforSeconds 30
179+ $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue(" Bearer" , $token )
180+ } else {
181+ $authBytes = [System.Text.Encoding ]::GetEncoding(" iso-8859-1" ).GetBytes(" $ ( $Username ) :$ ( $Password ) " )
182+ $client.DefaultRequestHeaders.Authorization = New-Object System.Net.Http.Headers.AuthenticationHeaderValue(" Basic" , [System.Convert ]::ToBase64String($authBytes ))
183+ }
177184
178185 if ($Credential ) {
179186 $client.Credentials = $Credential
You can’t perform that action at this time.
0 commit comments