Class: Conjur::Configuration
- Inherits:
-
Object
- Object
- Conjur::Configuration
- Defined in:
- lib/conjur/configuration.rb,
lib/conjur/pubkeys-api.rb
Overview
Stores a configuration for the Conjur API client. This class provides global and thread local storage for common options used by the Conjur API. Most importantly, it specifies the
- REST endpoints, derived from the #appliance_url and #account options
- The certificate used for secure connections to the Conjur appliance (#cert_file)
Environment Variables
Option values used by Conjur can be given by environment variables, using a standard naming scheme. Specifically,
an environment variable named CONJUR_ACCOUNT
will be used to provide a default value for the #account
option.
Required Options
The #account and #appliance_url are always required. Except in special cases, the #cert_file is also required, but you may omit it if your Conjur root certificate is in the OpenSSl default certificate store.
Thread Local Configuration
While using a globally available configuration is convenient for most applications, sometimes you will need to use different configurations in different threads. This is supported by returning a thread local version from configuration if one has been set by with_configuration.
Instance Attribute Summary collapse
-
#account ⇒ String
The organizational account used by Conjur.
-
#appliance_url ⇒ String
The url for your Conjur appliance.
-
#audit_url ⇒ String
The url for the Conjur audit service.
-
#authn_url ⇒ String
The url for the Conjur authentication service.
-
#authz_url ⇒ String
The url for the Conjur authorization service.
-
#cert_file ⇒ String?
Path to the certificate file to use when making secure connections to your Conjur appliance.
-
#core_url ⇒ String
The url for the Conjur core/directory service.
- #env ⇒ String deprecated Deprecated.
-
#pubkeys_url ⇒ String
The url for the Conjur public keys service.
Instance Method Summary collapse
-
#clone(override_options = {}) ⇒ Conjur::Configuration
Return a copy of this Configuration instance, optionally updating the copy with options from the
override_options
hash. -
#initialize(options = {}) ⇒ Configuration
constructor
Create a new Configuration, setting initial values from
options
.
Constructor Details
#initialize(options = {}) ⇒ Configuration
options
must use symbols for keys.
Create a new Conjur::Configuration, setting initial values from
options
.
182 183 184 185 |
# File 'lib/conjur/configuration.rb', line 182 def initialize = {} @explicit = .dup @supplied = .dup end |
Instance Attribute Details
#account ⇒ String
this option is required, and attempting to make any api calls prior to setting it (either
explicitly or with the "CONJUR_ACCOUNT"
environment variable) will raise an exception.
The organizational account used by Conjur.
On Conjur appliances, this option will be set once when the appliance is first configured. You can get the value for the acccount option from your conjur administrator, or if you have installed the Conjur command line tools by running conjur authn whoami, or examining your .conjurrc file.
354 |
# File 'lib/conjur/configuration.rb', line 354 add_option :account, required: true |
#appliance_url ⇒ String
If you are using an appliance (if you're not sure, you probably are), this option is required.
The url for your Conjur appliance.
If your appliance's hostname is 'conjur.companyname.com'
, then your appliance_url
will
be 'https://conjur.companyname.com/api'
.
331 |
# File 'lib/conjur/configuration.rb', line 331 add_option :appliance_url |
#audit_url ⇒ String
You should not generally set this value. Instead, Conjur will derive it from the #account and #appliance_url properties.
The url for the Conjur audit service.
318 319 320 |
# File 'lib/conjur/configuration.rb', line 318 add_option :audit_url do global_service_url 'audit', 300 end |
#authn_url ⇒ String
You should not generally set this value. Instead, Conjur will derive it from the #account and #appliance_url properties.
The url for the Conjur authentication service.
282 283 284 |
# File 'lib/conjur/configuration.rb', line 282 add_option :authn_url do account_service_url 'authn', 0 end |
#authz_url ⇒ String
You should not generally set this value. Instead, Conjur will derive it from the #account and #appliance_url properties.
The url for the Conjur authorization service.
294 295 296 |
# File 'lib/conjur/configuration.rb', line 294 add_option :authz_url do global_service_url 'authz', 100 end |
#cert_file ⇒ String?
Path to the certificate file to use when making secure connections to your Conjur appliance.
This should be the path to the root Conjur SSL certificate in PEM format. You will normally get the certificate file using the conjur init command. This option is not required if the certificate or its root is in the OpenSSL default cert store. If your program throws an error indicating that SSL verification has failed, you probably need to set or fix this option.
389 |
# File 'lib/conjur/configuration.rb', line 389 add_option :cert_file |
#core_url ⇒ String
You should not generally set this value. Instead, Conjur will derive it from the #account and #appliance_url properties.
The url for the Conjur core/directory service.
306 307 308 |
# File 'lib/conjur/configuration.rb', line 306 add_option :core_url do default_service_url 'core', 200 end |
#env ⇒ String
The type of environment your program is running in (e.g., development
, production
, test
).
364 365 366 |
# File 'lib/conjur/configuration.rb', line 364 add_option :env do ENV['CONJUR_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || "production" end |
#pubkeys_url ⇒ String
You should not generally set this value. Instead, Conjur will derive it from the #account and #appliance_url properties.
The url for the Conjur public keys service.
33 34 35 |
# File 'lib/conjur/pubkeys-api.rb', line 33 add_option :pubkeys_url do account_service_url 'pubkeys', 400 end |
Instance Method Details
#clone(override_options = {}) ⇒ Conjur::Configuration
Return a copy of this Conjur::Configuration instance, optionally
updating the copy with options from the override_options
hash.
258 259 260 |
# File 'lib/conjur/configuration.rb', line 258 def clone = {} self.class.new self.explicit.dup.merge() end |