Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion Documentation/Connect-IDNW.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,23 @@ This function connects to IdentityNow and sets the environment variables for the
## EXAMPLES
```powershell
-------------------------- EXAMPLE 1 --------------------------
Connect-IDNW -Instance "Sandbox"
Connect-IDNW -Instance "DEV" -APIVersion "beta"
Connects to the DEV instance using the beta API version.


-------------------------- EXAMPLE 2 --------------------------
Connect-IDNW -Instance "TST" -APIVersion "v3"
Connects to the TST instance using the v3 API version.


-------------------------- EXAMPLE 3 --------------------------
Connect-IDNW -Instance "ACC" -APIVersion "v3"
Connects to the ACC instance using the v3 API version.


-------------------------- EXAMPLE 4 --------------------------
Connect-IDNW -Instance "PRD" -APIVersion "v3" -UseSecretManagement
Connects to the PRD instance using the v3 API version and retrieves secrets using Microsoft.PowerShell.SecretManagement.

```

Expand Down
28 changes: 10 additions & 18 deletions PSIdentityNow/Private/Get-IDNWEnvironment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
This function gets the environment details for the specified IdentityNow instance. The function will return the base URL, the base API URL, the session token data, the session token, and the API version.

.EXAMPLE
Get-IDNWEnvironment -Instance "Sandbox"
Get-IDNWEnvironment

.PARAMETER Instance
The IdentityNow instance to get the environment details for.
Expand All @@ -28,7 +28,7 @@ function Get-IDNWEnvironment {
param (
[Parameter(Mandatory = $false)]
[Alias("Environment")]
[ValidateSet("Sandbox", "ACC", "PRD")]
[ValidateSet("DEV", "TST", "ACC", "PRD")]
[String]
$Instance,

Expand All @@ -55,22 +55,14 @@ function Get-IDNWEnvironment {
}

# Determine correct set of secrets for session
switch ($Instance.ToLower()) {
{ "sandbox", "acc" -contains $_ } {
$sail_base_url = Get-IDNWSecret -Name 'IDNW-ACC-BASE-URL' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_id = Get-IDNWSecret -Name 'IDNW-ACC-CLIENT-ID' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_secret = Get-IDNWSecret -Name 'IDNW-ACC-CLIENT-SECRET'-UseSecretManagement:$UseSecretManagement
}
"prd" {
$sail_base_url = Get-IDNWSecret -Name 'IDNW-PRD-BASE-URL' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_id = Get-IDNWSecret -Name 'IDNW-PRD-CLIENT-ID' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_secret = Get-IDNWSecret -Name 'IDNW-PRD-CLIENT-SECRET'-UseSecretManagement:$UseSecretManagement
}
default {
$sail_base_url = Get-IDNWSecret -Name 'IDNW-BASE-URL' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_id = Get-IDNWSecret -Name 'IDNW-CLIENT-ID' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_secret = Get-IDNWSecret -Name 'IDNW-CLIENT-SECRET'-UseSecretManagement:$UseSecretManagement
}
if($Instance) {
$sail_base_url = Get-IDNWSecret -Name "IDNW-$($Instance.ToUpper())-BASE-URL" -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_id = Get-IDNWSecret -Name "IDNW-$($Instance.ToUpper())-CLIENT-ID" -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_secret = Get-IDNWSecret -Name "IDNW-$($Instance.ToUpper())-CLIENT-SECRET" -UseSecretManagement:$UseSecretManagement
} else {
$sail_base_url = Get-IDNWSecret -Name 'IDNW-BASE-URL' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_id = Get-IDNWSecret -Name 'IDNW-CLIENT-ID' -AsPlainText -UseSecretManagement:$UseSecretManagement
$sail_client_secret = Get-IDNWSecret -Name 'IDNW-CLIENT-SECRET' -UseSecretManagement:$UseSecretManagement
}

$sessiontokendata = @{
Expand Down
26 changes: 15 additions & 11 deletions PSIdentityNow/Public/Connect-IDNW.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@
This function connects to IdentityNow and sets the environment variables for the specified instance.

.EXAMPLE
Connect-IDNW -Instance "Sandbox"
Connect-IDNW -Instance "DEV" -APIVersion "beta"
Connects to the DEV instance using the beta API version.

.EXAMPLE
Connect-IDNW -Instance "TST" -APIVersion "v3"
Connects to the TST instance using the v3 API version.

.EXAMPLE
Connect-IDNW -Instance "ACC" -APIVersion "v3"
Connects to the ACC instance using the v3 API version.

.EXAMPLE
Connect-IDNW -Instance "PRD" -APIVersion "v3" -UseSecretManagement
Connects to the PRD instance using the v3 API version and retrieves secrets using Microsoft.PowerShell.SecretManagement.

.PARAMETER Instance
The IdentityNow instance to connect to.
Expand Down Expand Up @@ -35,7 +48,7 @@ function Connect-IDNW {
param (
[Parameter(Mandatory = $false)]
[Alias("Environment")]
[ValidateSet("Sandbox", "ACC", "PRD")]
[ValidateSet("DEV", "TST", "ACC", "PRD")]
[String]
$Instance,

Expand All @@ -49,15 +62,6 @@ function Connect-IDNW {
$UseSecretManagement = $false
)

switch ($Instance.ToLower()) {
{ "sandbox" } {
$Instance = "Sandbox"
}
{ "prd", "acc" -contains $_ } {
$Instance = $_.ToUpper()
}
}

$Parameters = @{
APIVersion = $APIVersion
UseSecretManagement = $UseSecretManagement
Expand Down