Module: Conjur::Saas

Defined in:
lib/conjur/saas.rb

Overview

Detects whether a Conjur appliance URL points at CyberArk Secrets Manager, SaaS. SaaS appliances do not expose the '/info' or root version endpoints used to determine server version, so features that depend on those endpoints must be rejected outright for SaaS rather than attempting a version check.

Constant Summary collapse

SUFFIXES =

Hostname suffixes used by CyberArk Secrets Manager, SaaS appliances.

%w[
  .cyberark.cloud
  .integration-cyberark.cloud
  .test-cyberark.cloud
  .dev-cyberark.cloud
  .cyberark-everest-integdev.cloud
  .cyberark-everest-pre-prod.cloud
  .sandbox-cyberark.cloud
  .pt-cyberark.cloud
].freeze
HOSTNAME_PATTERN =
/(\.secretsmgr|-secretsmanager)(#{SUFFIXES.map { |s| Regexp.escape(s) }.join('|')})\z/.freeze

Class Method Summary collapse

Class Method Details

.appliance_url?(url) ⇒ Boolean

Returns true if url is a CyberArk Secrets Manager, SaaS appliance URL.

Parameters:

  • url (String, nil)

    the appliance URL to check.

Returns:

  • (Boolean)


27
28
29
30
31
32
33
34
35
36
37
# File 'lib/conjur/saas.rb', line 27

def self.appliance_url?(url)
  return false unless url

  uri = URI.parse(url)
  return false unless uri.scheme == 'https'
  return false unless uri.host

  !!(uri.host.downcase =~ HOSTNAME_PATTERN)
rescue URI::InvalidURIError, ArgumentError
  false
end