diff --git a/cmd/logon.go b/cmd/logon.go index a5a6937..2c4ad46 100644 --- a/cmd/logon.go +++ b/cmd/logon.go @@ -105,13 +105,22 @@ func startAuthIdentity(c pasapi.Client, username string) (*responses.Authenticat } // Start authentication - response, err := identity.StartAuthentication(c, startAuth) + response, err := identity.StartAuthentication(c, startAuth, "") if err != nil { return nil, fmt.Errorf("Failed to start authentication. %s", err) } if response.Success != true { return nil, fmt.Errorf("%s %s", identityUnsuccessfulResponse, *response.Message) } + if response.Result.PodFqdn != "" { + response, err = identity.StartAuthentication(c, startAuth, response.Result.PodFqdn) + if err != nil { + return nil, fmt.Errorf("Failed to start authentication. %s", err) + } + if response.Success != true { + return nil, fmt.Errorf("%s %s", identityUnsuccessfulResponse, *response.Message) + } + } return response, nil } @@ -148,6 +157,10 @@ var logonCmd = &cobra.Command{ if err != nil { log.Fatalf("Failed to get tenant ID. %s", err) } + if Verbose { + prettyprint.PrintColor("cyan", fmt.Sprintf("Tenant ID: %s", c.TenantID)) + prettyprint.PrintColor("cyan", fmt.Sprintf("Base URL: %s", c.BaseURL)) + } } // Get password from environment variable PAS_PASSWORD diff --git a/pkg/cybr/identity/startauth.go b/pkg/cybr/identity/startauth.go index 5f34e28..ec618b2 100644 --- a/pkg/cybr/identity/startauth.go +++ b/pkg/cybr/identity/startauth.go @@ -11,9 +11,15 @@ import ( "github.com/infamousjoeg/cybr-cli/pkg/cybr/identity/responses" ) +var identityTenant string + // StartAuthentication starts the authentication process -func StartAuthentication(c api.Client, req requests.StartAuthentication) (*responses.Authentication, error) { - identityTenant := fmt.Sprintf("https://%s.id.cyberark.cloud", req.TenantID) +func StartAuthentication(c api.Client, req requests.StartAuthentication, podFqdn string) (*responses.Authentication, error) { + if podFqdn == "" { + identityTenant = fmt.Sprintf("https://%s.id.cyberark.cloud", req.TenantID) + } else { + identityTenant = fmt.Sprintf("https://%s", podFqdn) + } url := fmt.Sprintf("%s/Security/StartAuthentication", identityTenant) headers := http.Header{} diff --git a/release.json b/release.json index b648ff3..132b1cd 100644 --- a/release.json +++ b/release.json @@ -1,4 +1,4 @@ { - "version": "1.0.0-release", + "version": "1.0.1-release", "go_version": "1.17.2" } \ No newline at end of file