From de262bdd3052cfc8bb5e604bbbe370bbb15d88cd Mon Sep 17 00:00:00 2001 From: Pete Maan Date: Fri, 9 Oct 2026 13:33:46 +0100 Subject: [PATCH 1/5] =?UTF-8?q?=E2=9A=A1=20Cache=20CurrentUser=20modules?= =?UTF-8?q?=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 26 +++++++++++++++++++------- CHANGELOG.md | 4 +++- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 798f65a..74d40c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,6 +63,16 @@ jobs: - uses: actions/checkout@v7 - name: Get Build Scripts run: git clone --depth 1 --branch $env:BUILD_REF https://github.com/pspete/pspete.Build build + # CurrentUser modules are cached; install.ps1 and help.ps1 skip those found. + # The key rolls monthly so newer module versions are picked up. + - name: Cache Month + id: month + run: '"month=$(Get-Date -Format yyyy-MM)" >> $env:GITHUB_OUTPUT' + - name: Cache Modules + uses: actions/cache@v6 + with: + path: ~/Documents/PowerShell/Modules + key: psmodules-test-${{ steps.month.outputs.month }} - name: Install Dependencies run: ./build/install.ps1 - name: Install IdentityCommand @@ -145,15 +155,19 @@ jobs: - name: PowerShell os: windows-latest shell: pwsh + modules: ~/Documents/PowerShell/Modules - name: WindowsPowerShell os: windows-latest shell: powershell + modules: ~/Documents/WindowsPowerShell/Modules - name: Linux os: ubuntu-latest shell: pwsh + modules: ~/.local/share/powershell/Modules #- name: Mac # os: macos-latest # shell: pwsh + # modules: ~/.local/share/powershell/Modules defaults: run: shell: ${{ matrix.shell }} @@ -168,18 +182,16 @@ jobs: with: name: module path: ${{ env.MODULE_NAME }} - # Windows PowerShell 5.1 has no PSResourceGet; install.ps1 skips its ~60s bootstrap when the module is found. - # The key rolls monthly so a newer PSResourceGet is picked up. + # CurrentUser modules are cached per leg; install.ps1 skips those found, including the PSResourceGet bootstrap on 5.1. + # The key rolls monthly so newer module versions are picked up. - name: Cache Month id: month - if: matrix.shell == 'powershell' run: '"month=$(Get-Date -Format yyyy-MM)" >> $env:GITHUB_OUTPUT' - - name: Cache PSResourceGet - if: matrix.shell == 'powershell' + - name: Cache Modules uses: actions/cache@v6 with: - path: ~/Documents/WindowsPowerShell/Modules/Microsoft.PowerShell.PSResourceGet - key: psresourceget-winps-${{ steps.month.outputs.month }} + path: ${{ matrix.modules }} + key: psmodules-${{ matrix.name }}-${{ steps.month.outputs.month }} - name: Install Dependencies run: ./build/install.ps1 - name: Install IdentityCommand diff --git a/CHANGELOG.md b/CHANGELOG.md index 550a97b..488d7e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file. ## Unreleased -- N/A +### Changed + +- CI caches the PowerShell modules it installs, so dependency installs skip the PowerShell Gallery on a cache hit. ## [0.6.68] - 2026-10-08 From c9daff69943b3b07bd68e30d0f8382d3af469903 Mon Sep 17 00:00:00 2001 From: Pete Maan Date: Mon, 12 Oct 2026 21:15:42 +0100 Subject: [PATCH 2/5] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Resolve=20service=20UR?= =?UTF-8?q?L=20lazily=20from=20the=20IdentityCommand=20session?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove Connect-SIATenant; commands resolve the service URL and sync auth via Resolve-RequestUrl on first use. Import the module at discovery in tests that call InModuleScope at file level. --- IdentityCommand.SIA/IdentityCommand.SIA.psd1 | 1 - IdentityCommand.SIA/IdentityCommand.SIA.psm1 | 6 +- .../Public/Add-SIAConnectorPoolMember.ps1 | 2 +- .../Public/Add-SIASSHHostKeyFingerprint.ps1 | 2 +- .../Public/Add-SIATargetSet.ps1 | 2 +- .../Public/Connect-SIATarget.ps1 | 2 +- .../Public/Connect-SIATenant.ps1 | 116 ---------- .../Public/Get-SIACertificate.ps1 | 2 +- .../Public/Get-SIAConnector.ps1 | 2 +- .../Public/Get-SIAConnectorSetupScript.ps1 | 2 +- .../Public/Get-SIADatabaseStrongAccount.ps1 | 4 +- .../Public/Get-SIADatabaseTarget.ps1 | 2 +- .../Public/Get-SIAHttpsRelay.ps1 | 2 +- .../Public/Get-SIAHttpsRelaySetupScript.ps1 | 2 +- IdentityCommand.SIA/Public/Get-SIAMFAKey.ps1 | 2 +- IdentityCommand.SIA/Public/Get-SIAPolicy.ps1 | 2 +- .../Public/Get-SIAResource.ps1 | 2 +- .../Public/Get-SIASSHHostKeyFingerprint.ps1 | 2 +- .../Public/Get-SIASSHPublicKey.ps1 | 2 +- IdentityCommand.SIA/Public/Get-SIASession.ps1 | 2 +- IdentityCommand.SIA/Public/Get-SIASetting.ps1 | 2 +- .../Public/Get-SIAStrongAccount.ps1 | 4 +- .../Public/Get-SIATargetSet.ps1 | 2 +- .../Public/Get-SIAVirtualMachine.ps1 | 2 +- ...Invoke-SIAConnectorCertificateRotation.ps1 | 2 +- ...nvoke-SIAHttpsRelayCertificateRotation.ps1 | 2 +- .../Public/Invoke-SIASSHPublicKeyRotation.ps1 | 2 +- .../Public/New-SIADatabaseStrongAccount.ps1 | 2 +- IdentityCommand.SIA/Public/New-SIAPolicy.ps1 | 2 +- .../Public/New-SIAStrongAccount.ps1 | 2 +- .../Public/Remove-SIAConnector.ps1 | 2 +- .../Remove-SIADatabaseStrongAccount.ps1 | 2 +- .../Public/Remove-SIAHttpsRelay.ps1 | 2 +- .../Public/Remove-SIAPolicy.ps1 | 2 +- .../Remove-SIASSHHostKeyFingerprint.ps1 | 2 +- .../Public/Remove-SIAStrongAccount.ps1 | 2 +- .../Public/Remove-SIATargetSet.ps1 | 2 +- .../Public/Remove-SIAVirtualMachine.ps1 | 2 +- .../Set-SIAConnectorMaintenanceMode.ps1 | 2 +- .../Public/Set-SIADatabaseStrongAccount.ps1 | 2 +- IdentityCommand.SIA/Public/Set-SIAPolicy.ps1 | 2 +- .../Public/Set-SIASSHHostKeyFingerprint.ps1 | 2 +- IdentityCommand.SIA/Public/Set-SIASetting.ps1 | 2 +- .../Public/Set-SIAStrongAccount.ps1 | 2 +- .../Public/Test-SIAConnector.ps1 | 2 +- .../Public/Update-SIAConnector.ps1 | 2 +- .../Public/Update-SIAHttpsRelay.ps1 | 2 +- Tests/Connect-SIATarget.Tests.ps1 | 8 + Tests/Connect-SIATenant.Tests.ps1 | 212 ------------------ Tests/Get-SIACertificate.Tests.ps1 | 8 + Tests/Get-SIAConnector.Tests.ps1 | 51 +++++ Tests/Get-SIAModuleData.Tests.ps1 | 8 + Tests/Get-SIAResource.Tests.ps1 | 8 + Tests/Get-SIASSHPublicKey.Tests.ps1 | 8 + Tests/Get-SIASession.Tests.ps1 | 8 + Tests/Get-SIASetting.Tests.ps1 | 8 + ...New-SIAPolicyConnectAsDefinition.Tests.ps1 | 8 + .../New-SIAPolicyFQDNRuleDefinition.Tests.ps1 | 8 + .../New-SIAPolicyProviderDefinition.Tests.ps1 | 8 + ...IAPolicyUserAccessRuleDefinition.Tests.ps1 | 8 + .../New-SIAPolicyUserDataDefinition.Tests.ps1 | 8 + 61 files changed, 198 insertions(+), 376 deletions(-) delete mode 100644 IdentityCommand.SIA/Public/Connect-SIATenant.ps1 delete mode 100644 Tests/Connect-SIATenant.Tests.ps1 diff --git a/IdentityCommand.SIA/IdentityCommand.SIA.psd1 b/IdentityCommand.SIA/IdentityCommand.SIA.psd1 index 0320c26..093fd5a 100644 --- a/IdentityCommand.SIA/IdentityCommand.SIA.psd1 +++ b/IdentityCommand.SIA/IdentityCommand.SIA.psd1 @@ -72,7 +72,6 @@ # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. FunctionsToExport = @( - 'Connect-SIATenant', 'Get-SIAModuleData', 'Get-SIAPolicy', 'Remove-SIAPolicy', diff --git a/IdentityCommand.SIA/IdentityCommand.SIA.psm1 b/IdentityCommand.SIA/IdentityCommand.SIA.psm1 index 1b065b5..c08a2b2 100644 --- a/IdentityCommand.SIA/IdentityCommand.SIA.psm1 +++ b/IdentityCommand.SIA/IdentityCommand.SIA.psm1 @@ -141,6 +141,7 @@ $ISPSSSession = [ordered]@{ User = $null TenantId = $null SessionId = $null + Subdomain = $null WebSession = $null StartTime = $null ElapsedTime = $null @@ -151,4 +152,7 @@ $ISPSSSession = [ordered]@{ LastErrorTime = $null } | Add-CustomType -Type IdCmd.Session -New-Variable -Name ISPSSSession -Value $ISPSSSession -Scope Script -Force \ No newline at end of file +New-Variable -Name ISPSSSession -Value $ISPSSSession -Scope Script -Force + +#Discovery key for Resolve-RequestUrl +New-Variable -Name ServiceKey -Value 'jit' -Scope Script -Force diff --git a/IdentityCommand.SIA/Public/Add-SIAConnectorPoolMember.ps1 b/IdentityCommand.SIA/Public/Add-SIAConnectorPoolMember.ps1 index 62c7635..feb40d6 100644 --- a/IdentityCommand.SIA/Public/Add-SIAConnectorPoolMember.ps1 +++ b/IdentityCommand.SIA/Public/Add-SIAConnectorPoolMember.ps1 @@ -19,7 +19,7 @@ function Add-SIAConnectorPoolMember { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/connector-pools/$connector_pool_id" + $URI = "$(Resolve-RequestUrl)/api/connectors/connector-pools/$connector_pool_id" #Create Request Body (ConvertTo-JsonBody keeps a single connector id a one-element JSON array) $body = ConvertTo-JsonBody -Body @{ diff --git a/IdentityCommand.SIA/Public/Add-SIASSHHostKeyFingerprint.ps1 b/IdentityCommand.SIA/Public/Add-SIASSHHostKeyFingerprint.ps1 index 3ca715c..40efcb3 100644 --- a/IdentityCommand.SIA/Public/Add-SIASSHHostKeyFingerprint.ps1 +++ b/IdentityCommand.SIA/Public/Add-SIASSHHostKeyFingerprint.ps1 @@ -22,7 +22,7 @@ function Add-SIASSHHostKeyFingerprint { process { - $URI = "$($ISPSSSession.tenant_url)/api/ssh-fingerprints" + $URI = "$(Resolve-RequestUrl)/api/ssh-fingerprints" #Create Request Body $body = $PSBoundParameters | Get-Parameter | ConvertTo-Json diff --git a/IdentityCommand.SIA/Public/Add-SIATargetSet.ps1 b/IdentityCommand.SIA/Public/Add-SIATargetSet.ps1 index 9b67a61..1eabb3f 100644 --- a/IdentityCommand.SIA/Public/Add-SIATargetSet.ps1 +++ b/IdentityCommand.SIA/Public/Add-SIATargetSet.ps1 @@ -52,7 +52,7 @@ function Add-SIATargetSet { process { - $URI = "$($ISPSSSession.tenant_url)/api/targetsets" + $URI = "$(Resolve-RequestUrl)/api/targetsets" #Create Request Body $boundParameters = $PSBoundParameters | Get-Parameter diff --git a/IdentityCommand.SIA/Public/Connect-SIATarget.ps1 b/IdentityCommand.SIA/Public/Connect-SIATarget.ps1 index 3ca2c88..31830b4 100644 --- a/IdentityCommand.SIA/Public/Connect-SIATarget.ps1 +++ b/IdentityCommand.SIA/Public/Connect-SIATarget.ps1 @@ -104,7 +104,7 @@ function Connect-SIATarget { process { - $URI = "$($ISPSSSession.tenant_url)/api/adb/sso/acquire" + $URI = "$(Resolve-RequestUrl)/api/adb/sso/acquire" switch ($PSCmdlet.ParameterSetName) { { $PSItem -match 'RDP$' } { diff --git a/IdentityCommand.SIA/Public/Connect-SIATenant.ps1 b/IdentityCommand.SIA/Public/Connect-SIATenant.ps1 deleted file mode 100644 index 2137c20..0000000 --- a/IdentityCommand.SIA/Public/Connect-SIATenant.ps1 +++ /dev/null @@ -1,116 +0,0 @@ -# .ExternalHelp IdentityCommand.SIA-help.xml -function Connect-SIATenant { - - [CmdletBinding(SupportsShouldProcess, DefaultParameterSetName = 'Subdomain')] - param( - - #subdomain - [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'Subdomain')] - [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'SubdomainCredential')] - [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'SubdomainSAML')] - [ValidateNotNullOrEmpty()] - [Alias('subdomain')] - [String]$tenant_subdomain, - - #tenant_url - [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'URL')] - [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'URLCredential')] - [parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, ParameterSetName = 'URLSAML')] - [ValidateNotNullOrEmpty()] - [Alias('sia_url')] - [String]$tenant_url, - - #Credential used to authenticate to CyberArk Identity. Authentication is performed even if an active IdentityCommand session is found, replacing it - [parameter(Mandatory = $true, ParameterSetName = 'SubdomainCredential')] - [parameter(Mandatory = $true, ParameterSetName = 'URLCredential')] - [ValidateNotNullOrEmpty()] - [PSCredential]$Credential, - - #Authenticate as a service user via New-IDPlatformToken (OAuth client_credentials) instead of the interactive New-IDSession - [parameter(ParameterSetName = 'SubdomainCredential')] - [parameter(ParameterSetName = 'URLCredential')] - [Switch]$PlatformToken, - - #SAML assertion used to authenticate to CyberArk Identity. Authentication is performed even if an active IdentityCommand session is found, replacing it - [parameter(Mandatory = $true, ParameterSetName = 'SubdomainSAML')] - [parameter(Mandatory = $true, ParameterSetName = 'URLSAML')] - [ValidateNotNullOrEmpty()] - [String]$SAMLResponse - - ) - - begin { - - $IDSession = Get-IDSession - $HaveSession = $null -ne $IDSession.tenant_url - $AuthRequested = $PSBoundParameters.ContainsKey('Credential') -or $PSBoundParameters.ContainsKey('SAMLResponse') - - if ($HaveSession -and $AuthRequested) { - Write-Verbose 'Authentication parameters were supplied; authenticating and replacing the existing IdentityCommand session' - } - - }#begin - - process { - - $UsingSubdomain = $PSCmdlet.ParameterSetName -like 'Subdomain*' - - #Resolve service URLs from platform discovery when a subdomain was supplied, or when - #authentication is required and the CyberArk Identity URL must be discovered. - $ServiceUrl = $null - - if ($UsingSubdomain) { - - $ServiceUrl = Resolve-ServiceUrl -Service jit -Subdomain $tenant_subdomain - $tenant_url = $ServiceUrl.ServiceUrl - - } else { - - #Ensure URL is in expected format - remove trailing slash if provided in Url - $tenant_url = $tenant_url -replace '/$', '' - - if ($AuthRequested) { - $ServiceUrl = Resolve-ServiceUrl -Service jit -Url $tenant_url - } - - } - - if ($AuthRequested -or (-not $HaveSession)) { - - if (-not $AuthRequested) { - throw 'Authenticate with New-IDSession or New-IDPlatformToken, or supply -Credential, and try again' - } - - $IdentityUrl = $ServiceUrl.IdentityUrl - - if ($PSCmdlet.ShouldProcess($IdentityUrl, 'Authenticate to CyberArk Identity')) { - - if ($PSCmdlet.ParameterSetName -like '*SAML') { - $null = New-IDSession -tenant_url $IdentityUrl -SAMLResponse $SAMLResponse - } elseif ($PlatformToken) { - $null = New-IDPlatformToken -tenant_url $IdentityUrl -Credential $Credential - } else { - $null = New-IDSession -tenant_url $IdentityUrl -Credential $Credential - } - - $IDSession = Get-IDSession - - } - - } - - #Make the CyberArk Identity Session available in the IdentityCommand.SIA scope - foreach ($key in $IDSession.keys) { - if ($null -ne $IDSession[$key]) { - $ISPSSSession[$key] = $IDSession[$key] - } - } - - #Set the SIA URL in the session data - $ISPSSSession.tenant_url = $tenant_url - - }#process - - end { }#end - -} diff --git a/IdentityCommand.SIA/Public/Get-SIACertificate.ps1 b/IdentityCommand.SIA/Public/Get-SIACertificate.ps1 index 18de299..ff433cd 100644 --- a/IdentityCommand.SIA/Public/Get-SIACertificate.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIACertificate.ps1 @@ -9,7 +9,7 @@ function Get-SIACertificate { process { - $URI = "$($ISPSSSession.tenant_url)/api/certificates" + $URI = "$(Resolve-RequestUrl)/api/certificates" #Send Request $result = Invoke-IDRestMethod -Uri $URI -Method GET diff --git a/IdentityCommand.SIA/Public/Get-SIAConnector.ps1 b/IdentityCommand.SIA/Public/Get-SIAConnector.ps1 index 7f54aaf..66ab117 100644 --- a/IdentityCommand.SIA/Public/Get-SIAConnector.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAConnector.ps1 @@ -14,7 +14,7 @@ function Get-SIAConnector { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/$connector_id" + $URI = "$(Resolve-RequestUrl)/api/connectors/$connector_id" #Send Request $result = Invoke-IDRestMethod -Uri $URI -Method GET diff --git a/IdentityCommand.SIA/Public/Get-SIAConnectorSetupScript.ps1 b/IdentityCommand.SIA/Public/Get-SIAConnectorSetupScript.ps1 index 3a94559..aab2b67 100644 --- a/IdentityCommand.SIA/Public/Get-SIAConnectorSetupScript.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAConnectorSetupScript.ps1 @@ -46,7 +46,7 @@ function Get-SIAConnectorSetupScript { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/setup-script" + $URI = "$(Resolve-RequestUrl)/api/connectors/setup-script" #Create Request Body $Body = $PSBoundParameters | Get-Parameter | ConvertTo-Json diff --git a/IdentityCommand.SIA/Public/Get-SIADatabaseStrongAccount.ps1 b/IdentityCommand.SIA/Public/Get-SIADatabaseStrongAccount.ps1 index bcad0a3..40b9ab6 100644 --- a/IdentityCommand.SIA/Public/Get-SIADatabaseStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIADatabaseStrongAccount.ps1 @@ -27,11 +27,11 @@ function Get-SIADatabaseStrongAccount { switch ($PSCmdlet.ParameterSetName) { 'ById' { - $URI = "$($ISPSSSession.tenant_url)/api/database-strong-accounts/$strong_account_id" + $URI = "$(Resolve-RequestUrl)/api/database-strong-accounts/$strong_account_id" } 'List' { - $URI = "$($ISPSSSession.tenant_url)/api/database-strong-accounts" + $URI = "$(Resolve-RequestUrl)/api/database-strong-accounts" $URI = Add-QueryString -URI $URI -Parameter ($PSBoundParameters | Get-Parameter) } diff --git a/IdentityCommand.SIA/Public/Get-SIADatabaseTarget.ps1 b/IdentityCommand.SIA/Public/Get-SIADatabaseTarget.ps1 index 90d6678..b788448 100644 --- a/IdentityCommand.SIA/Public/Get-SIADatabaseTarget.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIADatabaseTarget.ps1 @@ -15,7 +15,7 @@ function Get-SIADatabaseTarget { process { - $URI = "$($ISPSSSession.tenant_url)/api/database-targets" + $URI = "$(Resolve-RequestUrl)/api/database-targets" $URI = Add-QueryString -URI $URI -Parameter ($PSBoundParameters | Get-Parameter) diff --git a/IdentityCommand.SIA/Public/Get-SIAHttpsRelay.ps1 b/IdentityCommand.SIA/Public/Get-SIAHttpsRelay.ps1 index ceb970a..b3a74c6 100644 --- a/IdentityCommand.SIA/Public/Get-SIAHttpsRelay.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAHttpsRelay.ps1 @@ -9,7 +9,7 @@ function Get-SIAHttpsRelay { process { - $URI = "$($ISPSSSession.tenant_url)/api/https-relays" + $URI = "$(Resolve-RequestUrl)/api/https-relays" #Send Request $result = Invoke-IDRestMethod -Uri $URI -Method GET diff --git a/IdentityCommand.SIA/Public/Get-SIAHttpsRelaySetupScript.ps1 b/IdentityCommand.SIA/Public/Get-SIAHttpsRelaySetupScript.ps1 index e277c01..7d9dd14 100644 --- a/IdentityCommand.SIA/Public/Get-SIAHttpsRelaySetupScript.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAHttpsRelaySetupScript.ps1 @@ -46,7 +46,7 @@ function Get-SIAHttpsRelaySetupScript { process { - $URI = "$($ISPSSSession.tenant_url)/api/https-relays/setup-script" + $URI = "$(Resolve-RequestUrl)/api/https-relays/setup-script" #Create Request Body $body = $PSBoundParameters | Get-Parameter | ConvertTo-Json diff --git a/IdentityCommand.SIA/Public/Get-SIAMFAKey.ps1 b/IdentityCommand.SIA/Public/Get-SIAMFAKey.ps1 index 39b329b..ace07d2 100644 --- a/IdentityCommand.SIA/Public/Get-SIAMFAKey.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAMFAKey.ps1 @@ -14,7 +14,7 @@ function Get-SIAMFAKey { process { - $URI = "$($ISPSSSession.tenant_url)/api/ssh/sso/key" + $URI = "$(Resolve-RequestUrl)/api/ssh/sso/key" if ($PSBoundParameters.ContainsKey('format')) { $URI = "$URI`?format=$format" diff --git a/IdentityCommand.SIA/Public/Get-SIAPolicy.ps1 b/IdentityCommand.SIA/Public/Get-SIAPolicy.ps1 index b2824e1..d648a2d 100644 --- a/IdentityCommand.SIA/Public/Get-SIAPolicy.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAPolicy.ps1 @@ -28,7 +28,7 @@ function Get-SIAPolicy { process { - $URI = "$($ISPSSSession.tenant_url)/api/access-policies/$policyid" + $URI = "$(Resolve-RequestUrl)/api/access-policies/$policyid" if (-not $PSBoundParameters.ContainsKey('policyid')) { diff --git a/IdentityCommand.SIA/Public/Get-SIAResource.ps1 b/IdentityCommand.SIA/Public/Get-SIAResource.ps1 index 02f86c2..e8bb7bd 100644 --- a/IdentityCommand.SIA/Public/Get-SIAResource.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAResource.ps1 @@ -61,7 +61,7 @@ function Get-SIAResource { process { #Paramterset name is the url path to send the query to. - $URI = "$($ISPSSSession.tenant_url)/api/$($PSCmdlet.ParameterSetName)/$workspaceId" + $URI = "$(Resolve-RequestUrl)/api/$($PSCmdlet.ParameterSetName)/$workspaceId" #Send Request $result = Invoke-IDRestMethod -Uri $URI -Method GET diff --git a/IdentityCommand.SIA/Public/Get-SIASSHHostKeyFingerprint.ps1 b/IdentityCommand.SIA/Public/Get-SIASSHHostKeyFingerprint.ps1 index d47bd38..1245778 100644 --- a/IdentityCommand.SIA/Public/Get-SIASSHHostKeyFingerprint.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIASSHHostKeyFingerprint.ps1 @@ -14,7 +14,7 @@ function Get-SIASSHHostKeyFingerprint { process { - $URI = "$($ISPSSSession.tenant_url)/api/ssh-fingerprints/$target_id" + $URI = "$(Resolve-RequestUrl)/api/ssh-fingerprints/$target_id" #Send Request $result = Invoke-IDRestMethod -Uri $URI -Method GET diff --git a/IdentityCommand.SIA/Public/Get-SIASSHPublicKey.ps1 b/IdentityCommand.SIA/Public/Get-SIASSHPublicKey.ps1 index fcf3848..a9e915d 100644 --- a/IdentityCommand.SIA/Public/Get-SIASSHPublicKey.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIASSHPublicKey.ps1 @@ -65,7 +65,7 @@ function Get-SIASSHPublicKey { #workspace type switch and workspaceId, and sends both as query parameters. Confirm against a #tenant whether they are still accepted: aligning to the spec drops mandatory parameters and #is a breaking change, so it is not being done on the strength of the spec alone. - $URI = "$($ISPSSSession.tenant_url)/api/public-keys" + $URI = "$(Resolve-RequestUrl)/api/public-keys" $boundparameters = $PSBoundParameters | Get-Parameter -ParametersToRemove deploymentScript, AWS, AZURE, GCP, OnPrem diff --git a/IdentityCommand.SIA/Public/Get-SIASession.ps1 b/IdentityCommand.SIA/Public/Get-SIASession.ps1 index 3c3559b..bb101b9 100644 --- a/IdentityCommand.SIA/Public/Get-SIASession.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIASession.ps1 @@ -19,7 +19,7 @@ function Get-SIASession { process { - $URI = "$($ISPSSSession.tenant_url)/api/monitoring/sessions" + $URI = "$(Resolve-RequestUrl)/api/monitoring/sessions" $boundparameters = $PSBoundParameters | Get-Parameter diff --git a/IdentityCommand.SIA/Public/Get-SIASetting.ps1 b/IdentityCommand.SIA/Public/Get-SIASetting.ps1 index f35ae25..d13cc46 100644 --- a/IdentityCommand.SIA/Public/Get-SIASetting.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIASetting.ps1 @@ -18,7 +18,7 @@ function Get-SIASetting { process { - $URI = "$($ISPSSSession.tenant_url)/api/settings/$FeatureName" + $URI = "$(Resolve-RequestUrl)/api/settings/$FeatureName" #Send Request $result = Invoke-IDRestMethod -Uri $URI -Method GET diff --git a/IdentityCommand.SIA/Public/Get-SIAStrongAccount.ps1 b/IdentityCommand.SIA/Public/Get-SIAStrongAccount.ps1 index 489b0fa..944f05d 100644 --- a/IdentityCommand.SIA/Public/Get-SIAStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAStrongAccount.ps1 @@ -21,7 +21,7 @@ function Get-SIAStrongAccount { process { - $URI = "$($ISPSSSession.tenant_url)/api/secrets" + $URI = "$(Resolve-RequestUrl)/api/secrets" $URI = Add-QueryString -URI $URI -Parameter ($PSBoundParameters | Get-Parameter) @@ -34,7 +34,7 @@ function Get-SIAStrongAccount { #'count' query parameter is not enforced server-side - so the total has to come #from a dedicated endpoint, and pagination here is defensive: it only loops #further if fewer records came back than that reported total. - $CountURI = "$($ISPSSSession.tenant_url)/api/secrets/count" + $CountURI = "$(Resolve-RequestUrl)/api/secrets/count" $CountURI = Add-QueryString -URI $CountURI -Parameter ($PSBoundParameters | Get-Parameter -ParametersToKeep secret_type) diff --git a/IdentityCommand.SIA/Public/Get-SIATargetSet.ps1 b/IdentityCommand.SIA/Public/Get-SIATargetSet.ps1 index d78ea8f..cef7411 100644 --- a/IdentityCommand.SIA/Public/Get-SIATargetSet.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIATargetSet.ps1 @@ -19,7 +19,7 @@ function Get-SIATargetSet { process { - $URI = "$($ISPSSSession.tenant_url)/api/targetsets" + $URI = "$(Resolve-RequestUrl)/api/targetsets" $URI = Add-QueryString -URI $URI -Parameter ($PSBoundParameters | Get-Parameter) diff --git a/IdentityCommand.SIA/Public/Get-SIAVirtualMachine.ps1 b/IdentityCommand.SIA/Public/Get-SIAVirtualMachine.ps1 index 24da1f4..8b8564b 100644 --- a/IdentityCommand.SIA/Public/Get-SIAVirtualMachine.ps1 +++ b/IdentityCommand.SIA/Public/Get-SIAVirtualMachine.ps1 @@ -37,7 +37,7 @@ function Get-SIAVirtualMachine { #source, next_token, sort and search - neither is exposed here, so page size and the #single-source offset start point can't be controlled, only the cursor. Confirm against a #tenant before adding them. - $URI = "$($ISPSSSession.tenant_url)/api/infrastructure/virtual-machines" + $URI = "$(Resolve-RequestUrl)/api/infrastructure/virtual-machines" $URI = Add-QueryString -URI $URI -Parameter ($PSBoundParameters | Get-Parameter) diff --git a/IdentityCommand.SIA/Public/Invoke-SIAConnectorCertificateRotation.ps1 b/IdentityCommand.SIA/Public/Invoke-SIAConnectorCertificateRotation.ps1 index 70e0dc3..a772008 100644 --- a/IdentityCommand.SIA/Public/Invoke-SIAConnectorCertificateRotation.ps1 +++ b/IdentityCommand.SIA/Public/Invoke-SIAConnectorCertificateRotation.ps1 @@ -14,7 +14,7 @@ function Invoke-SIAConnectorCertificateRotation { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/$connector_id/rotate" + $URI = "$(Resolve-RequestUrl)/api/connectors/$connector_id/rotate" #The API requires an (empty) JSON body $body = '{}' diff --git a/IdentityCommand.SIA/Public/Invoke-SIAHttpsRelayCertificateRotation.ps1 b/IdentityCommand.SIA/Public/Invoke-SIAHttpsRelayCertificateRotation.ps1 index 7624894..6b55c18 100644 --- a/IdentityCommand.SIA/Public/Invoke-SIAHttpsRelayCertificateRotation.ps1 +++ b/IdentityCommand.SIA/Public/Invoke-SIAHttpsRelayCertificateRotation.ps1 @@ -13,7 +13,7 @@ function Invoke-SIAHttpsRelayCertificateRotation { process { - $URI = "$($ISPSSSession.tenant_url)/api/https-relays/$https_relay_id/rotate" + $URI = "$(Resolve-RequestUrl)/api/https-relays/$https_relay_id/rotate" #The API requires an (empty) JSON body $body = '{}' diff --git a/IdentityCommand.SIA/Public/Invoke-SIASSHPublicKeyRotation.ps1 b/IdentityCommand.SIA/Public/Invoke-SIASSHPublicKeyRotation.ps1 index 738c612..44f6a0f 100644 --- a/IdentityCommand.SIA/Public/Invoke-SIASSHPublicKeyRotation.ps1 +++ b/IdentityCommand.SIA/Public/Invoke-SIASSHPublicKeyRotation.ps1 @@ -30,7 +30,7 @@ function Invoke-SIASSHPublicKeyRotation { process { #Parameterset name is the url path to send the request to. - $URI = "$($ISPSSSession.tenant_url)/api/public-keys/rotation/$($PSCmdlet.ParameterSetName)" + $URI = "$(Resolve-RequestUrl)/api/public-keys/rotation/$($PSCmdlet.ParameterSetName)" if ($PSCmdlet.ShouldProcess('SSH CA Public Key', "Invoke Rotation Operation '$($PSCmdlet.ParameterSetName)'")) { diff --git a/IdentityCommand.SIA/Public/New-SIADatabaseStrongAccount.ps1 b/IdentityCommand.SIA/Public/New-SIADatabaseStrongAccount.ps1 index beff539..36e02e9 100644 --- a/IdentityCommand.SIA/Public/New-SIADatabaseStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/New-SIADatabaseStrongAccount.ps1 @@ -148,7 +148,7 @@ function New-SIADatabaseStrongAccount { process { - $URI = "$($ISPSSSession.tenant_url)/api/database-strong-accounts" + $URI = "$(Resolve-RequestUrl)/api/database-strong-accounts" #TODO the published strong account API spec for SIA databases documents this request body in #camelCase, where the fields sent below are snake_case - see the note in diff --git a/IdentityCommand.SIA/Public/New-SIAPolicy.ps1 b/IdentityCommand.SIA/Public/New-SIAPolicy.ps1 index a3cc03c..6a318ae 100644 --- a/IdentityCommand.SIA/Public/New-SIAPolicy.ps1 +++ b/IdentityCommand.SIA/Public/New-SIAPolicy.ps1 @@ -68,7 +68,7 @@ function New-SIAPolicy { process { - $URI = "$($ISPSSSession.tenant_url)/api/access-policies" + $URI = "$(Resolve-RequestUrl)/api/access-policies" #Get request parameters $boundParameters = $PSBoundParameters | Get-Parameter diff --git a/IdentityCommand.SIA/Public/New-SIAStrongAccount.ps1 b/IdentityCommand.SIA/Public/New-SIAStrongAccount.ps1 index 69cd694..20e895d 100644 --- a/IdentityCommand.SIA/Public/New-SIAStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/New-SIAStrongAccount.ps1 @@ -83,7 +83,7 @@ function New-SIAStrongAccount { } } - $URI = "$($ISPSSSession.tenant_url)/api/secrets" + $URI = "$(Resolve-RequestUrl)/api/secrets" switch ($PSCmdlet.ParameterSetName) { diff --git a/IdentityCommand.SIA/Public/Remove-SIAConnector.ps1 b/IdentityCommand.SIA/Public/Remove-SIAConnector.ps1 index 1e0fae9..b9641af 100644 --- a/IdentityCommand.SIA/Public/Remove-SIAConnector.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIAConnector.ps1 @@ -21,7 +21,7 @@ function Remove-SIAConnector { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/$connector_id" + $URI = "$(Resolve-RequestUrl)/api/connectors/$connector_id" if ($force_delete.IsPresent) { $URI = "$URI`?force_delete=true" diff --git a/IdentityCommand.SIA/Public/Remove-SIADatabaseStrongAccount.ps1 b/IdentityCommand.SIA/Public/Remove-SIADatabaseStrongAccount.ps1 index 1e372e2..d230b7f 100644 --- a/IdentityCommand.SIA/Public/Remove-SIADatabaseStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIADatabaseStrongAccount.ps1 @@ -14,7 +14,7 @@ function Remove-SIADatabaseStrongAccount { process { - $URI = "$($ISPSSSession.tenant_url)/api/database-strong-accounts/$strong_account_id" + $URI = "$(Resolve-RequestUrl)/api/database-strong-accounts/$strong_account_id" if ($PSCmdlet.ShouldProcess($strong_account_id, 'Delete SIA Database Strong Account')) { #Send Request diff --git a/IdentityCommand.SIA/Public/Remove-SIAHttpsRelay.ps1 b/IdentityCommand.SIA/Public/Remove-SIAHttpsRelay.ps1 index 9bf8d49..1c90ada 100644 --- a/IdentityCommand.SIA/Public/Remove-SIAHttpsRelay.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIAHttpsRelay.ps1 @@ -20,7 +20,7 @@ function Remove-SIAHttpsRelay { process { - $URI = "$($ISPSSSession.tenant_url)/api/https-relays/$https_relay_id" + $URI = "$(Resolve-RequestUrl)/api/https-relays/$https_relay_id" if ($force_delete.IsPresent) { $URI = "$URI`?force_delete=true" diff --git a/IdentityCommand.SIA/Public/Remove-SIAPolicy.ps1 b/IdentityCommand.SIA/Public/Remove-SIAPolicy.ps1 index 3106048..1743f5d 100644 --- a/IdentityCommand.SIA/Public/Remove-SIAPolicy.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIAPolicy.ps1 @@ -13,7 +13,7 @@ function Remove-SIAPolicy { process { - $URI = "$($ISPSSSession.tenant_url)/api/access-policies/$policyid" + $URI = "$(Resolve-RequestUrl)/api/access-policies/$policyid" if ($PSCmdlet.ShouldProcess($policyid, 'Delete SIA Policy')) { #Send Request diff --git a/IdentityCommand.SIA/Public/Remove-SIASSHHostKeyFingerprint.ps1 b/IdentityCommand.SIA/Public/Remove-SIASSHHostKeyFingerprint.ps1 index 67a93f6..1891b5f 100644 --- a/IdentityCommand.SIA/Public/Remove-SIASSHHostKeyFingerprint.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIASSHHostKeyFingerprint.ps1 @@ -14,7 +14,7 @@ function Remove-SIASSHHostKeyFingerprint { process { - $URI = "$($ISPSSSession.tenant_url)/api/ssh-fingerprints/$target_id" + $URI = "$(Resolve-RequestUrl)/api/ssh-fingerprints/$target_id" if ($PSCmdlet.ShouldProcess($target_id, 'Delete SIA SSH Host Key Fingerprint')) { diff --git a/IdentityCommand.SIA/Public/Remove-SIAStrongAccount.ps1 b/IdentityCommand.SIA/Public/Remove-SIAStrongAccount.ps1 index ec58c4e..5f5d710 100644 --- a/IdentityCommand.SIA/Public/Remove-SIAStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIAStrongAccount.ps1 @@ -14,7 +14,7 @@ function Remove-SIAStrongAccount { process { - $URI = "$($ISPSSSession.tenant_url)/api/secrets/$secret_id" + $URI = "$(Resolve-RequestUrl)/api/secrets/$secret_id" if ($PSCmdlet.ShouldProcess($secret_id, 'Delete SIA Strong Account')) { #Send Request diff --git a/IdentityCommand.SIA/Public/Remove-SIATargetSet.ps1 b/IdentityCommand.SIA/Public/Remove-SIATargetSet.ps1 index 6601811..f3f8d10 100644 --- a/IdentityCommand.SIA/Public/Remove-SIATargetSet.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIATargetSet.ps1 @@ -17,7 +17,7 @@ function Remove-SIATargetSet { process { - $URI = "$($ISPSSSession.tenant_url)/api/targetsets" + $URI = "$(Resolve-RequestUrl)/api/targetsets" if ($name.count -eq 1) { $URI = "$URI/$name" diff --git a/IdentityCommand.SIA/Public/Remove-SIAVirtualMachine.ps1 b/IdentityCommand.SIA/Public/Remove-SIAVirtualMachine.ps1 index d1b160c..f7c1fa0 100644 --- a/IdentityCommand.SIA/Public/Remove-SIAVirtualMachine.ps1 +++ b/IdentityCommand.SIA/Public/Remove-SIAVirtualMachine.ps1 @@ -15,7 +15,7 @@ function Remove-SIAVirtualMachine { process { - $URI = "$($ISPSSSession.tenant_url)/api/infrastructure/virtual-machines/$machine_id" + $URI = "$(Resolve-RequestUrl)/api/infrastructure/virtual-machines/$machine_id" if ($PSCmdlet.ShouldProcess($machine_id, 'Delete SIA VM Infrastructure Target')) { diff --git a/IdentityCommand.SIA/Public/Set-SIAConnectorMaintenanceMode.ps1 b/IdentityCommand.SIA/Public/Set-SIAConnectorMaintenanceMode.ps1 index 6c3af83..7c2ba68 100644 --- a/IdentityCommand.SIA/Public/Set-SIAConnectorMaintenanceMode.ps1 +++ b/IdentityCommand.SIA/Public/Set-SIAConnectorMaintenanceMode.ps1 @@ -20,7 +20,7 @@ function Set-SIAConnectorMaintenanceMode { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/$connector_id/maintenance" + $URI = "$(Resolve-RequestUrl)/api/connectors/$connector_id/maintenance" #Create Request Body $body = @{'maintenance' = $maintenance } | ConvertTo-Json diff --git a/IdentityCommand.SIA/Public/Set-SIADatabaseStrongAccount.ps1 b/IdentityCommand.SIA/Public/Set-SIADatabaseStrongAccount.ps1 index 73c706d..7199cac 100644 --- a/IdentityCommand.SIA/Public/Set-SIADatabaseStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/Set-SIADatabaseStrongAccount.ps1 @@ -155,7 +155,7 @@ function Set-SIADatabaseStrongAccount { process { - $URI = "$($ISPSSSession.tenant_url)/api/database-strong-accounts/$strong_account_id" + $URI = "$(Resolve-RequestUrl)/api/database-strong-accounts/$strong_account_id" #TODO the published strong account API spec for SIA databases documents this request body in #camelCase - storeType, accountProperties, accountName, passwordSecretObject, secretAccessKey, diff --git a/IdentityCommand.SIA/Public/Set-SIAPolicy.ps1 b/IdentityCommand.SIA/Public/Set-SIAPolicy.ps1 index 1d00d28..cbad38b 100644 --- a/IdentityCommand.SIA/Public/Set-SIAPolicy.ps1 +++ b/IdentityCommand.SIA/Public/Set-SIAPolicy.ps1 @@ -75,7 +75,7 @@ function Set-SIAPolicy { process { - $URI = "$($ISPSSSession.tenant_url)/api/access-policies/$policyid" + $URI = "$(Resolve-RequestUrl)/api/access-policies/$policyid" #Get existing policy settings $PolicySettings = Get-SIAPolicy -policyid $policyid diff --git a/IdentityCommand.SIA/Public/Set-SIASSHHostKeyFingerprint.ps1 b/IdentityCommand.SIA/Public/Set-SIASSHHostKeyFingerprint.ps1 index fc3ae26..f355fa8 100644 --- a/IdentityCommand.SIA/Public/Set-SIASSHHostKeyFingerprint.ps1 +++ b/IdentityCommand.SIA/Public/Set-SIASSHHostKeyFingerprint.ps1 @@ -22,7 +22,7 @@ function Set-SIASSHHostKeyFingerprint { process { - $URI = "$($ISPSSSession.tenant_url)/api/ssh-fingerprints" + $URI = "$(Resolve-RequestUrl)/api/ssh-fingerprints" #Create Request Body $body = $PSBoundParameters | Get-Parameter | ConvertTo-Json diff --git a/IdentityCommand.SIA/Public/Set-SIASetting.ps1 b/IdentityCommand.SIA/Public/Set-SIASetting.ps1 index 83b86aa..0670434 100644 --- a/IdentityCommand.SIA/Public/Set-SIASetting.ps1 +++ b/IdentityCommand.SIA/Public/Set-SIASetting.ps1 @@ -243,7 +243,7 @@ function Set-SIASetting { process { - $URI = "$($ISPSSSession.tenant_url)/api/settings/" + $URI = "$(Resolve-RequestUrl)/api/settings/" $FeatureName = $PSCmdlet.ParameterSetName diff --git a/IdentityCommand.SIA/Public/Set-SIAStrongAccount.ps1 b/IdentityCommand.SIA/Public/Set-SIAStrongAccount.ps1 index b40876c..b2660a9 100644 --- a/IdentityCommand.SIA/Public/Set-SIAStrongAccount.ps1 +++ b/IdentityCommand.SIA/Public/Set-SIAStrongAccount.ps1 @@ -106,7 +106,7 @@ function Set-SIAStrongAccount { } - $URI = "$($ISPSSSession.tenant_url)/api/secrets/$secret_id" + $URI = "$(Resolve-RequestUrl)/api/secrets/$secret_id" #Create Request Body (serialised to UTF8 bytes so the plaintext secret can't be captured - see helper). #-EmptyArrayProperty restores secret_details.domains to [] for Windows PowerShell. diff --git a/IdentityCommand.SIA/Public/Test-SIAConnector.ps1 b/IdentityCommand.SIA/Public/Test-SIAConnector.ps1 index 5de5142..be05e39 100644 --- a/IdentityCommand.SIA/Public/Test-SIAConnector.ps1 +++ b/IdentityCommand.SIA/Public/Test-SIAConnector.ps1 @@ -27,7 +27,7 @@ function Test-SIAConnector { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/$connector_id/reachability" + $URI = "$(Resolve-RequestUrl)/api/connectors/$connector_id/reachability" #Create Request Body. Each target is an object: @{ hostname = ''; port = } (port defaults to 22). #ConvertTo-JsonBody keeps a single supplied target a one-element JSON array. diff --git a/IdentityCommand.SIA/Public/Update-SIAConnector.ps1 b/IdentityCommand.SIA/Public/Update-SIAConnector.ps1 index 7c855e2..8831b9a 100644 --- a/IdentityCommand.SIA/Public/Update-SIAConnector.ps1 +++ b/IdentityCommand.SIA/Public/Update-SIAConnector.ps1 @@ -14,7 +14,7 @@ function Update-SIAConnector { process { - $URI = "$($ISPSSSession.tenant_url)/api/connectors/$connector_id/upgrade" + $URI = "$(Resolve-RequestUrl)/api/connectors/$connector_id/upgrade" #The API requires an (empty) JSON body $body = '{}' diff --git a/IdentityCommand.SIA/Public/Update-SIAHttpsRelay.ps1 b/IdentityCommand.SIA/Public/Update-SIAHttpsRelay.ps1 index a89bc94..926b8fb 100644 --- a/IdentityCommand.SIA/Public/Update-SIAHttpsRelay.ps1 +++ b/IdentityCommand.SIA/Public/Update-SIAHttpsRelay.ps1 @@ -13,7 +13,7 @@ function Update-SIAHttpsRelay { process { - $URI = "$($ISPSSSession.tenant_url)/api/https-relays/$https_relay_id/upgrade" + $URI = "$(Resolve-RequestUrl)/api/https-relays/$https_relay_id/upgrade" #The API requires an (empty) JSON body $body = '{}' diff --git a/Tests/Connect-SIATarget.Tests.ps1 b/Tests/Connect-SIATarget.Tests.ps1 index c9944ef..5181168 100644 --- a/Tests/Connect-SIATarget.Tests.ps1 +++ b/Tests/Connect-SIATarget.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/Connect-SIATenant.Tests.ps1 b/Tests/Connect-SIATenant.Tests.ps1 deleted file mode 100644 index f77ffac..0000000 --- a/Tests/Connect-SIATenant.Tests.ps1 +++ /dev/null @@ -1,212 +0,0 @@ -Describe $($PSCommandPath -Replace '.Tests.ps1') { - - BeforeAll { - #Get Current Directory - $Here = Split-Path -Parent $PSCommandPath - - #Module Name - $ModuleName = 'IdentityCommand.SIA' - - #Resolve Path to Module Directory - $ModulePath = Resolve-Path "$Here\..\$ModuleName" - - #Define Path to Module Manifest - $ManifestPath = Join-Path "$ModulePath" "$ModuleName.psd1" - - if ( -not (Get-Module -Name $ModuleName -All)) { - - Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop - - } - - } - - InModuleScope 'IdentityCommand.SIA' { - - BeforeEach { - - $ISPSSSession = [ordered]@{ - tenant_url = $null - User = $null - TenantId = $null - SessionId = $null - WebSession = $null - StartTime = $null - ElapsedTime = $null - LastCommand = $null - LastCommandTime = $null - LastCommandResults = $null - } - New-Variable -Name ISPSSSession -Value $ISPSSSession -Scope Script -Force - - Mock Get-IDSession -MockWith { - [ordered]@{ - tenant_url = 'https://somedomain.dpa.cyberark.cloud' - User = $null - TenantId = 'SomeTenant' - SessionId = 'SomeSession' - } - } - - Mock Resolve-ServiceUrl -MockWith { - [pscustomobject]@{ - ServiceUrl = 'https://SomeSubdomain.dpa.cyberark.cloud' - IdentityUrl = 'https://aao4818.id.cyberark.cloud' - } - } - - Mock New-IDSession -MockWith {} - Mock New-IDPlatformToken -MockWith {} - - Connect-SIATenant -tenant_url 'SomeURL' - - } - - Context 'Input' { - - It 'calls Get-IDSession' { - - Should -Invoke -CommandName Get-IDSession -Times 1 -Exactly -Scope It - - } - - It 'does not attempt authentication when an active session is found' { - - Should -Invoke -CommandName New-IDSession -Times 0 -Exactly -Scope It - Should -Invoke -CommandName New-IDPlatformToken -Times 0 -Exactly -Scope It - - } - - It 'authenticates when authentication parameters are supplied and a session already exists' { - - $Credential = [pscredential]::new('SomeUser', ('SomeSecret' | ConvertTo-SecureString -AsPlainText -Force)) - - Connect-SIATenant -tenant_url 'SomeURL' -Credential $Credential - - Should -Invoke -CommandName New-IDSession -Times 1 -Exactly -Scope It - - } - - It 'throws if no active session and no authentication parameters are supplied' { - - Mock Get-IDSession -MockWith { - [ordered]@{ - tenant_url = $null - User = $null - TenantId = 'SomeTenant' - SessionId = 'SomeSession' - } - } - - { Connect-SIATenant -tenant_url 'SomeURL' } | - Should -Throw 'Authenticate with New-IDSession or New-IDPlatformToken, or supply -Credential, and try again' - - } - - } - - Context 'Authentication' { - - BeforeEach { - - Mock Get-IDSession -MockWith { - [ordered]@{ - tenant_url = $null - User = $null - TenantId = 'SomeTenant' - SessionId = 'SomeSession' - } - } - - $Credential = [pscredential]::new('SomeUser', ('SomeSecret' | ConvertTo-SecureString -AsPlainText -Force)) - - } - - It 'resolves the CyberArk Identity URL from the supplied tenant_url' { - - Connect-SIATenant -tenant_url 'https://somedomain.dpa.cyberark.cloud' -Credential $Credential - - Should -Invoke -CommandName Resolve-ServiceUrl -ParameterFilter { - $Url -eq 'https://somedomain.dpa.cyberark.cloud' - } -Times 1 -Exactly -Scope It - - } - - It 'authenticates with New-IDSession using the discovered Identity URL when a credential is supplied' { - - Connect-SIATenant -tenant_url 'https://somedomain.dpa.cyberark.cloud' -Credential $Credential - - Should -Invoke -CommandName New-IDSession -ParameterFilter { - $tenant_url -eq 'https://aao4818.id.cyberark.cloud' -and $Credential.UserName -eq 'SomeUser' - } -Times 1 -Exactly -Scope It - - } - - It 'authenticates with New-IDPlatformToken when -PlatformToken is specified' { - - Connect-SIATenant -tenant_url 'https://somedomain.dpa.cyberark.cloud' -Credential $Credential -PlatformToken - - Should -Invoke -CommandName New-IDPlatformToken -ParameterFilter { - $tenant_url -eq 'https://aao4818.id.cyberark.cloud' - } -Times 1 -Exactly -Scope It - Should -Invoke -CommandName New-IDSession -Times 0 -Exactly -Scope It - - } - - It 'authenticates with New-IDSession using the SAML assertion when -SAMLResponse is supplied' { - - Connect-SIATenant -tenant_url 'https://somedomain.dpa.cyberark.cloud' -SAMLResponse 'SomeAssertion' - - Should -Invoke -CommandName New-IDSession -ParameterFilter { - $tenant_url -eq 'https://aao4818.id.cyberark.cloud' -and $SAMLResponse -eq 'SomeAssertion' - } -Times 1 -Exactly -Scope It - - } - - It 'resolves both SIA and Identity URLs from a supplied subdomain' { - - Connect-SIATenant -tenant_subdomain 'SomeSubdomain' -Credential $Credential - - Should -Invoke -CommandName Resolve-ServiceUrl -ParameterFilter { - $Subdomain -eq 'SomeSubdomain' - } -Times 1 -Exactly -Scope It - - $ISPSSSession.tenant_url | Should -Be 'https://SomeSubdomain.dpa.cyberark.cloud' - - } - - } - - Context 'Output' { - - It 'provides output with expected values' { - $ISPSSSession.tenant_url | Should -Not -BeNullOrEmpty - $ISPSSSession.tenant_url | Should -Be 'SomeURL' - $ISPSSSession.User | Should -BeNullOrEmpty - $ISPSSSession.TenantId | Should -Be 'SomeTenant' - $ISPSSSession.SessionId | Should -Be 'SomeSession' - - } - - It 'removes trailing space from provided tenant_url' { - Connect-SIATenant -tenant_url 'SomeURL/' - $ISPSSSession.tenant_url | Should -Be 'SomeURL' - } - - It 'resolves tenant_url from shared services when tenant_subdomain is provided' { - - Connect-SIATenant -tenant_subdomain 'SomeSubdomain' - - Should -Invoke -CommandName Resolve-ServiceUrl -ParameterFilter { - $Subdomain -eq 'SomeSubdomain' - } -Times 1 -Exactly -Scope It - - $ISPSSSession.tenant_url | Should -Be 'https://SomeSubdomain.dpa.cyberark.cloud' - - } - - } - - } - -} diff --git a/Tests/Get-SIACertificate.Tests.ps1 b/Tests/Get-SIACertificate.Tests.ps1 index b0450df..cc3c2e7 100644 --- a/Tests/Get-SIACertificate.Tests.ps1 +++ b/Tests/Get-SIACertificate.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/Get-SIAConnector.Tests.ps1 b/Tests/Get-SIAConnector.Tests.ps1 index 59c6b76..0f14ce8 100644 --- a/Tests/Get-SIAConnector.Tests.ps1 +++ b/Tests/Get-SIAConnector.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { @@ -115,6 +123,49 @@ Describe $($PSCommandPath -Replace '.Tests.ps1') { } + Context 'Without a module session' { + + BeforeEach { + + $ISPSSSession = [ordered]@{ + tenant_url = $null + Subdomain = $null + StartTime = $null + WebSession = $null + } + New-Variable -Name ISPSSSession -Value $ISPSSSession -Scope Script -Force + + Mock -CommandName Get-IDSession -MockWith { + [ordered]@{ + tenant_url = 'https://sometenant.id.cyberark.cloud' + Subdomain = 'sometenant' + StartTime = Get-Date '2026-01-01T09:00:00' + WebSession = New-Object Microsoft.PowerShell.Commands.WebRequestSession + } + } + + Mock -CommandName Resolve-ServiceUrl -MockWith { + [pscustomobject]@{ ServiceUrl = "https://$Subdomain.$Service.cyberark.cloud" } + } + + } + + It 'resolves the service URL from the IdentityCommand session' { + $null = Get-SIAConnector + Should -Invoke -CommandName Resolve-ServiceUrl -ParameterFilter { + $Service -eq 'jit' -and $Subdomain -eq 'sometenant' + } -Times 1 -Exactly -Scope It + } + + It 'sends request to the resolved service URL' { + $null = Get-SIAConnector + Should -Invoke -CommandName Invoke-IDRestMethod -ParameterFilter { + $URI -eq 'https://sometenant.jit.cyberark.cloud/api/connectors/' + } -Times 1 -Exactly -Scope It + } + + } + } } \ No newline at end of file diff --git a/Tests/Get-SIAModuleData.Tests.ps1 b/Tests/Get-SIAModuleData.Tests.ps1 index 0f951c5..105feae 100644 --- a/Tests/Get-SIAModuleData.Tests.ps1 +++ b/Tests/Get-SIAModuleData.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/Get-SIAResource.Tests.ps1 b/Tests/Get-SIAResource.Tests.ps1 index b629fa0..efb8736 100644 --- a/Tests/Get-SIAResource.Tests.ps1 +++ b/Tests/Get-SIAResource.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/Get-SIASSHPublicKey.Tests.ps1 b/Tests/Get-SIASSHPublicKey.Tests.ps1 index c89d69d..a8bafb7 100644 --- a/Tests/Get-SIASSHPublicKey.Tests.ps1 +++ b/Tests/Get-SIASSHPublicKey.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/Get-SIASession.Tests.ps1 b/Tests/Get-SIASession.Tests.ps1 index d7ddabb..214523d 100644 --- a/Tests/Get-SIASession.Tests.ps1 +++ b/Tests/Get-SIASession.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/Get-SIASetting.Tests.ps1 b/Tests/Get-SIASetting.Tests.ps1 index 4124d39..d70d9d1 100644 --- a/Tests/Get-SIASetting.Tests.ps1 +++ b/Tests/Get-SIASetting.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/New-SIAPolicyConnectAsDefinition.Tests.ps1 b/Tests/New-SIAPolicyConnectAsDefinition.Tests.ps1 index b9e6755..b8063ac 100644 --- a/Tests/New-SIAPolicyConnectAsDefinition.Tests.ps1 +++ b/Tests/New-SIAPolicyConnectAsDefinition.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/New-SIAPolicyFQDNRuleDefinition.Tests.ps1 b/Tests/New-SIAPolicyFQDNRuleDefinition.Tests.ps1 index 06d8752..00c3517 100644 --- a/Tests/New-SIAPolicyFQDNRuleDefinition.Tests.ps1 +++ b/Tests/New-SIAPolicyFQDNRuleDefinition.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/New-SIAPolicyProviderDefinition.Tests.ps1 b/Tests/New-SIAPolicyProviderDefinition.Tests.ps1 index 2c85e4e..c6dfd39 100644 --- a/Tests/New-SIAPolicyProviderDefinition.Tests.ps1 +++ b/Tests/New-SIAPolicyProviderDefinition.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/New-SIAPolicyUserAccessRuleDefinition.Tests.ps1 b/Tests/New-SIAPolicyUserAccessRuleDefinition.Tests.ps1 index 9cd4401..05ef430 100644 --- a/Tests/New-SIAPolicyUserAccessRuleDefinition.Tests.ps1 +++ b/Tests/New-SIAPolicyUserAccessRuleDefinition.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { diff --git a/Tests/New-SIAPolicyUserDataDefinition.Tests.ps1 b/Tests/New-SIAPolicyUserDataDefinition.Tests.ps1 index 6e75e17..a406db9 100644 --- a/Tests/New-SIAPolicyUserDataDefinition.Tests.ps1 +++ b/Tests/New-SIAPolicyUserDataDefinition.Tests.ps1 @@ -1,3 +1,11 @@ +#InModuleScope below runs at discovery, so the module must be imported before then +BeforeDiscovery { + $ManifestPath = Join-Path (Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\IdentityCommand.SIA") 'IdentityCommand.SIA.psd1' + if ( -not (Get-Module -Name 'IdentityCommand.SIA' -All)) { + Import-Module -Name "$ManifestPath" -ArgumentList $true -Force -ErrorAction Stop + } +} + Describe $($PSCommandPath -Replace '.Tests.ps1') { BeforeAll { From ac9c7bc42dcf8797a51561ac024c93b6356fb727 Mon Sep 17 00:00:00 2001 From: Pete Maan Date: Mon, 12 Oct 2026 21:43:37 +0100 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=93=9D=20Document=20the=20lazy=20serv?= =?UTF-8?q?ice=20connection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace the Connect step in the README and getting started docs with New-IDSession/New-IDPlatformToken, remove the Connect command doc and help, and add the CHANGELOG entries. --- CHANGELOG.md | 8 + .../en-US/IdentityCommand.SIA-help.xml | 452 ------------------ README.md | 26 +- .../_commands/Connect-SIATenant.md | 207 -------- docs/getting-started.md | 23 +- docs/index.md | 2 +- 6 files changed, 24 insertions(+), 694 deletions(-) delete mode 100644 docs/collections/_commands/Connect-SIATenant.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 488d7e2..3b022eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,18 @@ All notable changes to this project will be documented in this file. ## Unreleased +### Added + +- Commands find the Secure Infrastructure Access service url from the `IdentityCommand` session on first use, so no connection step is needed after `New-IDSession` or `New-IDPlatformToken`. Commands follow a later `New-IDSession` or `New-IDPlatformToken`, and fail after `Close-IDSession` until you authenticate again. + ### Changed - CI caches the PowerShell modules it installs, so dependency installs skip the PowerShell Gallery on a cache hit. +### Removed + +- `Connect-SIATenant`. Authenticate with `New-IDSession` or `New-IDPlatformToken` from `IdentityCommand` instead. + ## [0.6.68] - 2026-10-08 ### Changed diff --git a/IdentityCommand.SIA/en-US/IdentityCommand.SIA-help.xml b/IdentityCommand.SIA/en-US/IdentityCommand.SIA-help.xml index a3f0a9a..34dc254 100644 --- a/IdentityCommand.SIA/en-US/IdentityCommand.SIA-help.xml +++ b/IdentityCommand.SIA/en-US/IdentityCommand.SIA-help.xml @@ -907,458 +907,6 @@ - - - Connect-SIATenant - Connect - SIATenant - - Connects to a SIA tenant - - - - Connects to a SIA tenant to be able to run IdentityCommand.SIA module commands against it. - Provide either the ISPSS shared services subdomain (the SIA API url is resolved automatically via platform discovery) or the SIA tenant url directly. - If an active `IdentityCommand` session is already present (established with `New-IDSession` or `New-IDPlatformToken`), it is used as-is. - Supply `-Credential` (or `-SAMLResponse`) and `Connect-SIATenant` will authenticate to CyberArk Identity first, replacing any existing session: the Identity tenant url is discovered from the same subdomain / url via platform discovery, then `New-IDSession` (interactive user, including any MFA challenges) or - with `-PlatformToken` - `New-IDPlatformToken` (OAuth `client_credentials`, for a service user) is invoked. - - - - Connect-SIATenant - - tenant_subdomain - - The ISPSS shared services subdomain of the SIA tenant. The SIA API url is resolved from platform discovery and used for subsequent operations. - - String - - String - - - None - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - - Connect-SIATenant - - tenant_subdomain - - The ISPSS shared services subdomain of the SIA tenant. The SIA API url is resolved from platform discovery and used for subsequent operations. - - String - - String - - - None - - - Credential - - Credential used to authenticate to CyberArk Identity. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. A user credential is used with `New-IDSession`; a service user credential is used with `New-IDPlatformToken` when `-PlatformToken` is also specified. - - PSCredential - - PSCredential - - - None - - - PlatformToken - - Authenticate as a service user via `New-IDPlatformToken` (OAuth `client_credentials`) rather than the interactive `New-IDSession`. - - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - - Connect-SIATenant - - tenant_subdomain - - The ISPSS shared services subdomain of the SIA tenant. The SIA API url is resolved from platform discovery and used for subsequent operations. - - String - - String - - - None - - - SAMLResponse - - SAML assertion used to authenticate to CyberArk Identity via `New-IDSession`. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. - - String - - String - - - None - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - - Connect-SIATenant - - tenant_url - - The url of the SIA tenant - - String - - String - - - None - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - - Connect-SIATenant - - tenant_url - - The url of the SIA tenant - - String - - String - - - None - - - Credential - - Credential used to authenticate to CyberArk Identity. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. A user credential is used with `New-IDSession`; a service user credential is used with `New-IDPlatformToken` when `-PlatformToken` is also specified. - - PSCredential - - PSCredential - - - None - - - PlatformToken - - Authenticate as a service user via `New-IDPlatformToken` (OAuth `client_credentials`) rather than the interactive `New-IDSession`. - - - SwitchParameter - - - False - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - - Connect-SIATenant - - tenant_url - - The url of the SIA tenant - - String - - String - - - None - - - SAMLResponse - - SAML assertion used to authenticate to CyberArk Identity via `New-IDSession`. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. - - String - - String - - - None - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - - SwitchParameter - - - False - - - - - - tenant_subdomain - - The ISPSS shared services subdomain of the SIA tenant. The SIA API url is resolved from platform discovery and used for subsequent operations. - - String - - String - - - None - - - tenant_url - - The url of the SIA tenant - - String - - String - - - None - - - Credential - - Credential used to authenticate to CyberArk Identity. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. A user credential is used with `New-IDSession`; a service user credential is used with `New-IDPlatformToken` when `-PlatformToken` is also specified. - - PSCredential - - PSCredential - - - None - - - PlatformToken - - Authenticate as a service user via `New-IDPlatformToken` (OAuth `client_credentials`) rather than the interactive `New-IDSession`. - - SwitchParameter - - SwitchParameter - - - False - - - SAMLResponse - - SAML assertion used to authenticate to CyberArk Identity via `New-IDSession`. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. - - String - - String - - - None - - - WhatIf - - Shows what would happen if the cmdlet runs. The cmdlet is not run. - - SwitchParameter - - SwitchParameter - - - False - - - Confirm - - Prompts you for confirmation before running the cmdlet. - - SwitchParameter - - SwitchParameter - - - False - - - - - - System.String - - - - - - - - - - System.Object - - - - - - - - - - - - - - -------------------------- Example 1 -------------------------- - Connect-SIATenant -tenant_subdomain sometenant - - Resolves the SIA API url for the `sometenant` shared services subdomain and connects to it, using the active `IdentityCommand` session, for subsequent module operations - - - - -------------------------- Example 2 -------------------------- - Connect-SIATenant -tenant_url https://sometenant.dpa.cyberark.cloud - - Connects to the https://sometenant.dpa.cyberark.cloud SIA tenant, using the active `IdentityCommand` session, for subsequent module operations - - - - -------------------------- Example 3 -------------------------- - Connect-SIATenant -tenant_subdomain sometenant -Credential $Credential - - When no active `IdentityCommand` session is present, discovers the CyberArk Identity url for the `sometenant` subdomain, authenticates the user in `$Credential` (completing any MFA challenges), resolves the SIA API url and connects to it - - - - -------------------------- Example 4 -------------------------- - Connect-SIATenant -tenant_subdomain sometenant -Credential $ServiceUserCredential -PlatformToken - - When no active `IdentityCommand` session is present, authenticates non-interactively as a service user via an OAuth platform token, then connects to the `sometenant` SIA tenant - - - - - Get-SIACertificate diff --git a/README.md b/README.md index 349cf5d..08ebb5d 100644 --- a/README.md +++ b/README.md @@ -32,28 +32,19 @@ An overview of some of the features of the module are found in the below section ### SIA Authentication -The `Connect-SIATenant` command initialises the bearer token used for module operations against the SIA service. - -If an Identity session already exists (established with the `IdentityCommand` module's `New-IDSession` or `New-IDPlatformToken`), it is used as-is: +Authenticate with the `IdentityCommand` module, using `New-IDSession` (interactive user, including any MFA challenges) or `New-IDPlatformToken` (non-interactive service user). Commands find the SIA service url from the Identity session on first use - no separate connection step is needed: ```powershell -# Resolve the SIA API url automatically from the shared services subdomain -Connect-SIATenant -tenant_subdomain sometenant - -# Or provide the SIA tenant url directly -Connect-SIATenant -tenant_url https://sometenant.dpa.cyberark.cloud -``` +# Interactive user authentication +New-IDSession -tenant_url https://abc1234.id.cyberark.cloud -Credential $Credential -Otherwise, provide a credential and `Connect-SIATenant` authenticates to CyberArk Identity for you - the Identity tenant url is discovered from the same subdomain / url: - -```powershell -# Interactive user authentication (any MFA challenges are handled by IdentityCommand) -Connect-SIATenant -tenant_subdomain sometenant -Credential $Credential +# Or non-interactive service user authentication via an OAuth platform token +New-IDPlatformToken -tenant_url https://abc1234.id.cyberark.cloud -Credential $ServiceUserCredential -# Non-interactive service user authentication via an OAuth platform token -Connect-SIATenant -tenant_subdomain sometenant -Credential $ServiceUserCredential -PlatformToken +Get-SIAConnector ``` +Commands follow the current Identity session: a later `New-IDSession` or `New-IDPlatformToken` is used by the next command, and after `Close-IDSession` commands fail until you authenticate again. ### SIA Connections The `Connect-SIATarget` command can be use to initiate SIA connections to targets. @@ -167,7 +158,7 @@ List commands (`Get-SIAPolicy`, `Get-SIASession`, `Get-SIAStrongAccount`, `Get-S ### Tab Completion -Id and name parameters for policies, strong accounts, target sets, connectors and HTTPS relays support tab completion, sourced live from the corresponding `Get-SIA*` command, once connected with `Connect-SIATenant`. +Id and name parameters for policies, strong accounts, target sets, connectors and HTTPS relays support tab completion, sourced live from the corresponding `Get-SIA*` command, once authenticated with `New-IDSession` or `New-IDPlatformToken`. ## List Of Commands @@ -177,7 +168,6 @@ The full list of commands currently available in the _`IdentityCommand.SIA`_ mod | Function | Description | | ----------------------------------------- | ------------------------------------------------------------------------------ | -| `Connect-SIATenant` | Connects to a SIA tenant, using or establishing an `IdentityCommand` session | | `Connect-SIATarget` | Connect via RDP or SSH to SIA targets | | `Add-SIATargetSet` | Adds a SIA Target Set | | `Get-SIACertificate` | Get details of SIA certificates | diff --git a/docs/collections/_commands/Connect-SIATenant.md b/docs/collections/_commands/Connect-SIATenant.md deleted file mode 100644 index 894e516..0000000 --- a/docs/collections/_commands/Connect-SIATenant.md +++ /dev/null @@ -1,207 +0,0 @@ ---- -external help file: IdentityCommand.SIA-help.xml -Module Name: IdentityCommand.SIA -online version: -schema: 2.0.0 ---- - -# Connect-SIATenant - -## SYNOPSIS -Connects to a SIA tenant - -## SYNTAX - -### Subdomain (Default) -``` -Connect-SIATenant [-tenant_subdomain] [-WhatIf] [-Confirm] [] -``` - -### SubdomainCredential -``` -Connect-SIATenant [-tenant_subdomain] -Credential [-PlatformToken] [-WhatIf] [-Confirm] - [] -``` - -### SubdomainSAML -``` -Connect-SIATenant [-tenant_subdomain] -SAMLResponse [-WhatIf] [-Confirm] [] -``` - -### URL -``` -Connect-SIATenant [-tenant_url] [-WhatIf] [-Confirm] [] -``` - -### URLCredential -``` -Connect-SIATenant [-tenant_url] -Credential [-PlatformToken] [-WhatIf] [-Confirm] - [] -``` - -### URLSAML -``` -Connect-SIATenant [-tenant_url] -SAMLResponse [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Connects to a SIA tenant to be able to run IdentityCommand.SIA module commands against it. - -Provide either the ISPSS shared services subdomain (the SIA API url is resolved automatically via platform discovery) or the SIA tenant url directly. - -If an active `IdentityCommand` session is already present (established with `New-IDSession` or `New-IDPlatformToken`), it is used as-is. - -Supply `-Credential` (or `-SAMLResponse`) and `Connect-SIATenant` will authenticate to CyberArk Identity first, replacing any existing session: the Identity tenant url is discovered from the same subdomain / url via platform discovery, then `New-IDSession` (interactive user, including any MFA challenges) or - with `-PlatformToken` - `New-IDPlatformToken` (OAuth `client_credentials`, for a service user) is invoked. - -## EXAMPLES - -### Example 1 -``` -Connect-SIATenant -tenant_subdomain sometenant -``` - -Resolves the SIA API url for the `sometenant` shared services subdomain and connects to it, using the active `IdentityCommand` session, for subsequent module operations - -### Example 2 -``` -Connect-SIATenant -tenant_url https://sometenant.dpa.cyberark.cloud -``` - -Connects to the https://sometenant.dpa.cyberark.cloud SIA tenant, using the active `IdentityCommand` session, for subsequent module operations - -### Example 3 -``` -Connect-SIATenant -tenant_subdomain sometenant -Credential $Credential -``` - -When no active `IdentityCommand` session is present, discovers the CyberArk Identity url for the `sometenant` subdomain, authenticates the user in `$Credential` (completing any MFA challenges), resolves the SIA API url and connects to it - -### Example 4 -``` -Connect-SIATenant -tenant_subdomain sometenant -Credential $ServiceUserCredential -PlatformToken -``` - -When no active `IdentityCommand` session is present, authenticates non-interactively as a service user via an OAuth platform token, then connects to the `sometenant` SIA tenant - -## PARAMETERS - -### -tenant_subdomain -The ISPSS shared services subdomain of the SIA tenant. -The SIA API url is resolved from platform discovery and used for subsequent operations. - -```yaml -Type: String -Parameter Sets: Subdomain, SubdomainCredential, SubdomainSAML -Aliases: subdomain - -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -tenant_url -The url of the SIA tenant - -```yaml -Type: String -Parameter Sets: URL, URLCredential, URLSAML -Aliases: sia_url - -Required: True -Position: 0 -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Credential -Credential used to authenticate to CyberArk Identity. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. -A user credential is used with `New-IDSession`; a service user credential is used with `New-IDPlatformToken` when `-PlatformToken` is also specified. - -```yaml -Type: PSCredential -Parameter Sets: SubdomainCredential, URLCredential -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PlatformToken -Authenticate as a service user via `New-IDPlatformToken` (OAuth `client_credentials`) rather than the interactive `New-IDSession`. - -```yaml -Type: SwitchParameter -Parameter Sets: SubdomainCredential, URLCredential -Aliases: - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SAMLResponse -SAML assertion used to authenticate to CyberArk Identity via `New-IDSession`. Authentication is performed even if an active `IdentityCommand` session is found, replacing it. - -```yaml -Type: String -Parameter Sets: SubdomainSAML, URLSAML -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### CommonParameters -This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String -## OUTPUTS - -### System.Object -## NOTES - -## RELATED LINKS diff --git a/docs/getting-started.md b/docs/getting-started.md index ff930d3..618177e 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -107,25 +107,16 @@ The `IdentityCommand` module must be installed and available in order to use `Id An overview of some of the features of the module are found in the below sections. -The `Connect-SIATenant` command initialises the bearer token used for module operations against the SIA service. - -If an Identity session already exists (established with the `IdentityCommand` module's `New-IDSession` or `New-IDPlatformToken`), it is used as-is: +Authenticate with the `IdentityCommand` module, using `New-IDSession` (interactive user, including any MFA challenges) or `New-IDPlatformToken` (non-interactive service user). Commands find the SIA service url from the Identity session on first use - no separate connection step is needed: ```powershell -# Resolve the SIA API url automatically from the shared services subdomain -Connect-SIATenant -tenant_subdomain sometenant - -# Or provide the SIA tenant url directly -Connect-SIATenant -tenant_url https://sometenant.dpa.cyberark.cloud -``` +# Interactive user authentication +New-IDSession -tenant_url https://abc1234.id.cyberark.cloud -Credential $Credential -Otherwise, provide a credential and `Connect-SIATenant` authenticates to CyberArk Identity for you - the Identity tenant url is discovered from the same subdomain / url: - -```powershell -# Interactive user authentication (any MFA challenges are handled by IdentityCommand) -Connect-SIATenant -tenant_subdomain sometenant -Credential $Credential +# Or non-interactive service user authentication via an OAuth platform token +New-IDPlatformToken -tenant_url https://abc1234.id.cyberark.cloud -Credential $ServiceUserCredential -# Non-interactive service user authentication via an OAuth platform token -Connect-SIATenant -tenant_subdomain sometenant -Credential $ServiceUserCredential -PlatformToken +Get-SIAConnector ``` +Commands follow the current Identity session: a later `New-IDSession` or `New-IDPlatformToken` is used by the next command, and after `Close-IDSession` commands fail until you authenticate again. diff --git a/docs/index.md b/docs/index.md index fa50045..1d8a315 100644 --- a/docs/index.md +++ b/docs/index.md @@ -125,5 +125,5 @@ List commands (`Get-SIAPolicy`, `Get-SIASession`, `Get-SIAStrongAccount`, `Get-S ## Tab Completion -Id and name parameters for policies, strong accounts, target sets, connectors and HTTPS relays support tab completion, sourced live from the corresponding `Get-SIA*` command, once connected with `Connect-SIATenant`. +Id and name parameters for policies, strong accounts, target sets, connectors and HTTPS relays support tab completion, sourced live from the corresponding `Get-SIA*` command, once authenticated with `New-IDSession` or `New-IDPlatformToken`. From 77b49b0433cbd1ac084799d8c860cc87b4686fc6 Mon Sep 17 00:00:00 2001 From: Pete Maan Date: Mon, 12 Oct 2026 23:48:51 +0100 Subject: [PATCH 4/5] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Require=20IdentityComm?= =?UTF-8?q?and=201.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 1 + IdentityCommand.SIA/IdentityCommand.SIA.psd1 | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74d40c6..ff41e0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ env: # vNext releases are prereleases: -preview. PRERELEASE_LABEL: ${{ github.ref == 'refs/heads/vNext' && 'preview' || '' }} # IdentityCommand version installed for tests and packaging; the module copies its private helpers. - IDENTITYCOMMAND_VERSION: '0.7.159' + IDENTITYCOMMAND_VERSION: '1.0.0' defaults: run: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b022eb..35aeb02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. ### Changed +- Requires `IdentityCommand` 1.0.0. - CI caches the PowerShell modules it installs, so dependency installs skip the PowerShell Gallery on a cache hit. ### Removed diff --git a/IdentityCommand.SIA/IdentityCommand.SIA.psd1 b/IdentityCommand.SIA/IdentityCommand.SIA.psd1 index 093fd5a..0614c56 100644 --- a/IdentityCommand.SIA/IdentityCommand.SIA.psd1 +++ b/IdentityCommand.SIA/IdentityCommand.SIA.psd1 @@ -52,7 +52,7 @@ # Modules that must be imported into the global environment prior to importing this module RequiredModules = @( - @{ModuleName = 'IdentityCommand'; GUID = 'f6bb2bdf-0c53-443f-be07-3c25264a09b1'; ModuleVersion = '0.7.159' } + @{ModuleName = 'IdentityCommand'; GUID = 'f6bb2bdf-0c53-443f-be07-3c25264a09b1'; ModuleVersion = '1.0.0' } ) # Assemblies that must be loaded prior to importing this module From c7f0902aa0c01b6ee77f25988ae18e4188b158b4 Mon Sep 17 00:00:00 2001 From: Pete Maan Date: Tue, 13 Oct 2026 21:35:09 +0100 Subject: [PATCH 5/5] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Require=20IdentityComm?= =?UTF-8?q?and=201.0.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Picks up the session expired message for a 401 on an expired token. --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 4 +++- IdentityCommand.SIA/IdentityCommand.SIA.psd1 | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ff41e0a..8ac813e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ env: # vNext releases are prereleases: -preview. PRERELEASE_LABEL: ${{ github.ref == 'refs/heads/vNext' && 'preview' || '' }} # IdentityCommand version installed for tests and packaging; the module copies its private helpers. - IDENTITYCOMMAND_VERSION: '1.0.0' + IDENTITYCOMMAND_VERSION: '1.0.1' defaults: run: diff --git a/CHANGELOG.md b/CHANGELOG.md index 35aeb02..918b149 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,9 @@ All notable changes to this project will be documented in this file. ### Changed -- Requires `IdentityCommand` 1.0.0. +- Requires `IdentityCommand` 1.0.1. +- A request refused with 401 because the session token has expired reports `Session expired at