Last active
April 1, 2021 19:52
-
-
Save telday/c26b65b9cbe805ded2fe25579b98513f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#### Conjur Service Broker Implementation | |
require 'conjur-api' | |
def api(appliance_url) | |
Conjur.configure do |config| | |
config.account = ENV['CONJUR_ACCOUNT'] | |
config.appliance_url = appliance_url | |
config.ssl_certificate = ConjurClient.ssl_cert | |
config.version = ConjurClient.version | |
end | |
Conjur.configuration.apply_cert_config! | |
Conjur::API.new_from_key ENV['CONJUR_AUTHN_LOGIN'] | |
ENV['CONJUR_AUTHN_API_KEY'] | |
end | |
#### Out of the box client | |
require 'openapi_client' | |
# Setup the default Conjur configuration | |
OpenapiClient.configure do |config| | |
config.host = ENV['APPLIANCE_URL'] | |
config.username = ENV['CONJUR_AUTHN_LOGIN'] | |
config.password = ENV['CONJUR_AUTHN_API_KEY'] | |
config.ssl_ca_cert = ENV['CONJUR_SSL_CERTIFICATE'] | |
config.api_key_prefix['Authorization'] = "Token" | |
# Instantiate a new authentication api instance | |
authn_api = OpenapiClient::AuthenticationApi.new | |
token = authn_api.get_access_token( | |
ENV['CONJUR_ACCOUNT'], | |
ENV['CONJUR_AUTHN_LOGIN'], | |
ENV['CONJUR_AUTHN_API_KEY'], | |
opt={accept_encoding: 'base64'} | |
) | |
config.api_key['Authorization'] = "token=\"#{token}\"" | |
end | |
# Perform our operation | |
secrets_api = OpenapiClient::SecretsApi.new | |
secrets_api.create_secret(ENV['CONJUR_ACCOUNT'], 'variable', 'superSecret') | |
#### Update naming scheme | |
require 'conjur-sdk' | |
# Setup the default Conjur configuration | |
ConjurSDK.configure do |config| | |
config.host = ENV['APPLIANCE_URL'] | |
config.username = ENV['CONJUR_AUTHN_LOGIN'] | |
config.password = ENV['CONJUR_AUTHN_API_KEY'] | |
config.ssl_ca_cert = ENV['CONJUR_SSL_CERTIFICATE'] | |
config.api_key_prefix['Authorization'] = "Token" | |
# Instantiate a new authentication api instance | |
authn_api = ConjurSDK::AuthenticationApi.new | |
token = authn_api.get_access_token( | |
ENV['CONJUR_ACCOUNT'], | |
ENV['CONJUR_AUTHN_LOGIN'], | |
ENV['CONJUR_AUTHN_API_KEY'], | |
opt={accept_encoding: 'base64'} | |
) | |
config.api_key['Authorization'] = "token=\"#{token}\"" | |
end | |
# Perform our operation | |
secrets_api = ConjurSDK::SecretsApi.new | |
secrets_api.create_secret(ENV['CONJUR_ACCOUNT'], 'variable', 'superSecret') | |
#### Add Support for Environmental variables | |
require 'conjur-sdk' | |
# Setup the default Conjur configuration | |
ConjurSDK::Configuration.default.setup_access_token | |
# Perform our operation | |
secrets_api = ConjurSDK::SecretsApi.new | |
secrets_api.create_secret(ENV['CONJUR_ACCOUNT'], 'variable', 'superSecret') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment