Sha256: 32033320f763a444b955566d0d58a6f3bf27ac7fcd3ead5e8ae9012e71b1295a

Contents?: true

Size: 1.8 KB

Versions: 1

Compression:

Stored size: 1.8 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/config/api_proxy_configuration'
require 'contrast/config/certification_configuration'
require 'contrast/config/request_audit_configuration'

module Contrast
  module Config
    # Api keys configuration
    class ApiConfiguration < BaseConfiguration
      # @return [String]
      attr_accessor :api_key
      # @return [String]
      attr_accessor :user_name
      # @return [String]
      attr_accessor :service_key
      attr_writer :url, :proxy, :request_audit, :certificate

      DEFAULT_URL = 'https://app.contrastsecurity.com/Contrast'

      def initialize hsh = {}
        @api_key = traverse_config(hsh, :api_key)
        @url = traverse_config(hsh, :url)
        @user_name = traverse_config(hsh, :user_name)
        @service_key = traverse_config(hsh, :service_key)
        @proxy = Contrast::Config::ApiProxyConfiguration.new(traverse_config(hsh, :proxy))
        @request_audit = Contrast::Config::RequestAuditConfiguration.new(traverse_config(hsh, :request_audit))
        @certificate = Contrast::Config::CertificationConfiguration.new(traverse_config(hsh, :certificate))
      end

      def url
        @url.nil? ? DEFAULT_URL : @url
      end

      # @return [Contrast::Config::ApiProxyConfiguration]
      def proxy
        @proxy ||= Contrast::Config::ApiProxyConfiguration.new
      end

      # @return [Contrast::Config::RequestAuditConfiguration]
      def request_audit
        @request_audit ||= Contrast::Config::RequestAuditConfiguration.new
      end

      # @return [Contrast::Config::CertificationConfiguration]
      def certificate
        @certificate ||= Contrast::Config::CertificationConfiguration.new
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
contrast-agent-6.0.0 lib/contrast/config/api_configuration.rb