common

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package common provides common models and utilities for AWS environment management and configuration handling within the ARK SDK. This package contains environment type definitions, environment detection utilities, and mapping configurations for different AWS environments including production and government cloud deployments.

Package common provides common data models and utilities for the ARK SDK. This package contains shared data types and helper functions that are used across different components of the ARK SDK for consistent data handling.

Index

Constants

View Source
const (
	AppCodeSIA  = "SIA"
	AppCodeDPA  = "DPA"
	AppCodeCSM  = "CSM"
	AppCodePAM  = "PAM"
	AppCodeDAP  = "DAP"
	AppCodeITI  = "ITI"
	AppCodeUBA  = "UBA"
	AppCodeADM  = "ADM"
	AppCodeAUD  = "AUD"
	AppCodeALR  = "ALR"
	AppCodeCEM  = "CEM"
	AppCodeEPM  = "EPM"
	AppCodeSCA  = "SCA"
	AppCodeSHSM = "SHSM"
	AppCodeCLO  = "CLO"
	AppCodeCMS  = "CMS"
	AppCodeSMS  = "SMS"
	AppCodePYC  = "PYC"
	AppCodeARS  = "ARS"
	AppCodeIDP  = "IDP"
	AppCodeITDR = "ITDR"
	AppCodeINTS = "INTS"
	AppCodeMSP  = "MSP"
	AppCodeCCE  = "CCE"
)

Application codes for sessions.

View Source
const (
	CategoryTypeCloudConsole = "Cloud console"
	CategoryTypeVM           = "VM"
	CategoryTypeDB           = "DB"
)

ArkCategoryType represents the type of category in Ark.

View Source
const (
	ConnectionMethodStanding = "standing"
	ConnectionMethodDynamic  = "dynamic"
)

Possible connection methods.

View Source
const (
	// DeployEnv is the environment variable name used to determine the current deployment environment.
	DeployEnv = "DEPLOY_ENV"
	// IdentityTenantName is the default tenant name used for identity services.
	IdentityTenantName = "isp"
)

Environment variable and tenant configuration constants.

These constants define the standard environment variables and default values used for environment detection and tenant configuration across different AWS environments.

View Source
const (
	OSTypeWindows = "windows"
	OSTypeDarwin  = "darwin"
	OSTypeLinux   = "linux"
)

Possible operating systems

View Source
const (
	ProtocolTypeSSH     = "SSH"
	ProtocolTypeRDP     = "RDP"
	ProtocolTypeCLI     = "CLI"
	ProtocolTypeCONSOLE = "CONSOLE"
	ProtocolTypeHTTPS   = "HTTPS"
	ProtocolTypeK8S     = "K8S"
	ProtocolTypeDB      = "DB"
)

Protocol types for sessions.

View Source
const (
	WorkspaceTypeAWS    = "AWS"
	WorkspaceTypeAzure  = "AZURE"
	WorkspaceTypeOnPrem = "ON-PREMISE"
	WorkspaceTypeGCP    = "GCP"
	WorkspaceTypeFQDNIP = "FQDN/IP"
	WorkspaceTypeATLAS  = "ATLAS"
	WorkspaceTypeFault  = "FAULT"
)

Possible workspace types

Variables

View Source
var IdentityEnvUrls = map[AwsEnv]string{
	Prod:    "idaptive.app",
	GovProd: "id.cyberarkgov.cloud",
}

IdentityEnvUrls maps AWS environments to their respective identity service URLs.

This mapping provides the identity service endpoints for each AWS environment. These URLs are used for authentication and identity management operations and vary between standard AWS and GovCloud deployments.

View Source
var IdentityGeneratedSuffixPattern = map[AwsEnv]string{
	Prod:    `cyberark\.cloud\.\d.*`,
	GovProd: `cyberarkgov\.cloud\.\d.*`,
}

IdentityGeneratedSuffixPattern maps AWS environments to their respective regex patterns.

These patterns are used to validate and identify auto-generated identity suffixes for each AWS environment. The patterns help distinguish between different environment-specific tenant naming conventions and ensure proper tenant routing.

IdentityTenantNames maps AWS environments to their respective identity tenant names.

This mapping provides the default tenant names used for identity services in each AWS environment. Currently, both environments use the same default tenant name, but this mapping allows for environment-specific customization.

View Source
var RootDomain = map[AwsEnv]string{
	Prod:    "cyberark.cloud",
	GovProd: "cyberarkgov.cloud",
}

RootDomain maps AWS environments to their respective root domain names.

This mapping provides the base domain for each AWS environment, which is used to construct various service endpoints and URLs throughout the ARK SDK. The root domains differ between standard AWS and GovCloud environments.

Functions

func CheckIfIdentityGeneratedSuffix

func CheckIfIdentityGeneratedSuffix(tenantSuffix string, env AwsEnv) bool

CheckIfIdentityGeneratedSuffix validates if a tenant suffix matches the environment-specific pattern.

This function checks whether the provided tenant suffix matches the expected pattern for auto-generated identity suffixes in the specified AWS environment. It uses regex patterns defined in IdentityGeneratedSuffixPattern to perform the validation, helping to ensure proper tenant routing and identification.

Parameters:

  • tenantSuffix: The tenant suffix string to validate against the pattern
  • env: The AWS environment to check the pattern against

Returns true if the tenant suffix matches the environment's pattern, false otherwise. Returns false if the environment is not recognized or the pattern match fails.

Example:

// Check production environment suffix
isValid := CheckIfIdentityGeneratedSuffix("cyberark.cloud.123", Prod)
if isValid {
    // Handle auto-generated tenant
}

// Check GovCloud environment suffix
isValid = CheckIfIdentityGeneratedSuffix("cyberarkgov.cloud.456", GovProd)

func IsGovCloud

func IsGovCloud() bool

IsGovCloud determines if the current AWS region is a government cloud region.

This function checks the AWS region environment variables to determine if the current deployment is running in an AWS GovCloud region. It first checks the AWS_REGION environment variable, and if that's not set, falls back to checking AWS_DEFAULT_REGION. GovCloud regions are identified by the "us-gov" prefix.

Returns true if the current region is a GovCloud region, false otherwise. Returns false if no region environment variables are set.

Example:

// Set GovCloud region
os.Setenv("AWS_REGION", "us-gov-west-1")
if IsGovCloud() {
    // Configure for GovCloud deployment
    env := GovProd
}

// Standard AWS region
os.Setenv("AWS_REGION", "us-east-1")
if !IsGovCloud() {
    // Configure for standard AWS deployment
    env := Prod
}

Types

type ArkRFC3339Time

type ArkRFC3339Time time.Time

ArkRFC3339Time is a custom time type that represents a time in RFC 3339 format. This type provides JSON marshaling and unmarshaling capabilities for time values that need to be serialized in RFC 3339 format with microsecond precision. It wraps the standard time.Time type and implements the json.Marshaler and json.Unmarshaler interfaces for proper JSON handling.

Example usage:

var arkTime ArkRFC3339Time
err := json.Unmarshal([]byte(`"2023-01-01T12:00:00.123456Z"`), &arkTime)
if err != nil {
	// handle error
}

func (*ArkRFC3339Time) MarshalJSON

func (ct *ArkRFC3339Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for ArkRFC3339Time. It converts an ArkRFC3339Time value to JSON format by formatting the underlying time value as an RFC 3339 string with microsecond precision.

The method formats the time using the customTimeFormat constant and returns the result as a JSON-encoded string value.

Returns:

  • []byte: JSON-encoded byte array containing the formatted time string
  • error: nil if marshaling succeeds, otherwise an error from json.Marshal

Example output: "2023-01-01T12:00:00.123456Z"

func (*ArkRFC3339Time) UnmarshalJSON

func (ct *ArkRFC3339Time) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for ArkRFC3339Time. It parses JSON data containing a time string in RFC 3339 format with microsecond precision and converts it to an ArkRFC3339Time value.

The method handles both quoted and unquoted JSON strings, automatically removing surrounding quotes if present. It uses the customTimeFormat constant to parse the time string with the expected RFC 3339 format.

Parameters:

  • data: JSON byte data containing the time string to parse

Returns:

  • error: nil if parsing succeeds, otherwise an error describing the parse failure

Example JSON input: "2023-01-01T12:00:00.123456Z"

type AwsEnv

type AwsEnv string

AwsEnv represents the AWS environment type used throughout the ARK SDK.

This type is used to distinguish between different AWS deployment environments such as production and government cloud environments. It provides type safety when working with environment-specific configurations and mappings.

const (
	// Prod represents the standard AWS production environment.
	Prod AwsEnv = "prod"
	// GovProd represents the AWS GovCloud production environment.
	GovProd AwsEnv = "gov-prod"
)

Supported AWS environments for ARK SDK deployments.

These constants define the available AWS environments that the ARK SDK can operate within. Each environment has specific configurations and endpoint mappings defined in the associated maps below.

func GetDeployEnv

func GetDeployEnv() AwsEnv

GetDeployEnv returns the current AWS environment based on the DEPLOY_ENV environment variable.

This function reads the DEPLOY_ENV environment variable to determine the current deployment environment. If the environment variable is not set or is empty, it defaults to the production environment for backward compatibility.

Returns the AwsEnv corresponding to the current deployment environment.

Example:

// Set environment variable
os.Setenv("DEPLOY_ENV", "gov-prod")
env := GetDeployEnv()
if env == GovProd {
    // Handle GovCloud-specific logic
}

// Default behavior when not set
os.Unsetenv("DEPLOY_ENV")
env = GetDeployEnv() // Returns Prod

Directories

Path Synopsis
Package identity provides data structures and types for ARK Identity directory services.
Package identity provides data structures and types for ARK Identity directory services.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL