conjur-cli 5.6.6 → 6.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.dockerignore +1 -1
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -1
- data/APPLIANCE_VERSION +1 -1
- data/CHANGELOG.md +3 -42
- data/Gemfile +4 -7
- data/Humanfile.md +31 -0
- data/Jenkinsfile +34 -63
- data/README.md +41 -55
- data/Rakefile +5 -1
- data/bin/conjur +0 -2
- data/build-deb.sh +1 -3
- data/ci/cli-test.sh +6 -0
- data/ci/package.sh +3 -1
- data/ci/publish.sh +2 -2
- data/ci/secrets/publish.yml +2 -2
- data/ci/wait_for_server.sh +10 -0
- data/conjur-cli.gemspec +7 -7
- data/dev/docker-compose.yml +24 -0
- data/dev/start.sh +15 -0
- data/dev/stop.sh +5 -0
- data/docker-compose.yml +30 -0
- data/features/authentication/authenticate.feature +34 -0
- data/features/authentication/login.feature +13 -0
- data/features/authentication/logout.feature +15 -0
- data/{acceptance-features → features}/authentication/whoami.feature +0 -0
- data/features/authorization/resource/annotate.feature +22 -0
- data/features/authorization/resource/check.feature +47 -0
- data/{acceptance-features → features}/authorization/resource/exists.feature +18 -6
- data/features/authorization/resource/permitted_roles.feature +35 -0
- data/features/authorization/resource/show.feature +34 -0
- data/features/authorization/role/exists.feature +28 -0
- data/features/authorization/role/members.feature +45 -0
- data/features/authorization/role/memberships.feature +43 -0
- data/features/conjurenv/check.feature +34 -0
- data/features/conjurenv/run.feature +15 -0
- data/{acceptance-features → features}/conjurenv/template.feature +8 -3
- data/{acceptance-features → features}/directory/user/update_password.feature +8 -2
- data/{acceptance-features → features}/directory/variable/value.feature +9 -5
- data/{acceptance-features → features}/directory/variable/values-add.feature +8 -3
- data/features/hostfactory/tokens.feature +22 -0
- data/features/pubkeys/show.feature +18 -0
- data/features/step_definitions/authn_steps.rb +22 -0
- data/features/step_definitions/cli_steps.rb +28 -0
- data/features/step_definitions/file_steps.rb +12 -0
- data/features/step_definitions/flow_control_steps.rb +7 -0
- data/features/step_definitions/graph_steps.rb +4 -3
- data/{acceptance-features → features}/step_definitions/http_steps.rb +0 -0
- data/features/step_definitions/overrides.rb +9 -0
- data/features/step_definitions/policy_steps.rb +11 -0
- data/{acceptance-features → features}/step_definitions/trusted_proxy_steps.rb +0 -0
- data/features/support/blank.yml +1 -0
- data/features/support/env.rb +21 -7
- data/features/support/hooks.rb +31 -116
- data/features/support/world.rb +16 -76
- data/jenkins.sh +33 -0
- data/lib/conjur/authenticator.rb +83 -0
- data/lib/conjur/authn.rb +5 -20
- data/lib/conjur/cli.rb +13 -6
- data/lib/conjur/command.rb +30 -350
- data/lib/conjur/command/authn.rb +23 -15
- data/lib/conjur/command/host_factories.rb +2 -74
- data/lib/conjur/command/hosts.rb +6 -113
- data/lib/conjur/command/init.rb +20 -35
- data/lib/conjur/command/{secrets.rb → policies.rb} +33 -22
- data/lib/conjur/command/pubkeys.rb +3 -63
- data/lib/conjur/command/resources.rb +45 -162
- data/lib/conjur/command/roles.rb +11 -181
- data/lib/conjur/command/rspec/helpers.rb +0 -1
- data/lib/conjur/command/rspec/mock_services.rb +4 -4
- data/lib/conjur/command/users.rb +2 -159
- data/lib/conjur/command/variables.rb +5 -218
- data/lib/conjur/complete.rb +2 -2
- data/lib/conjur/config.rb +1 -11
- data/lib/conjur/conjurenv.rb +12 -9
- data/lib/conjur/identifier_manipulation.rb +3 -5
- data/lib/conjur/version.rb +2 -2
- data/{publish-rubygem.sh → publish.sh} +0 -4
- data/spec/authn_spec.rb +4 -0
- data/spec/command/hosts_spec.rb +2 -69
- data/spec/command/init_spec.rb +16 -11
- data/spec/command/pubkeys_spec.rb +1 -46
- data/spec/command/resources_spec.rb +21 -170
- data/spec/command/roles_spec.rb +5 -181
- data/spec/command/users_spec.rb +3 -79
- data/spec/command_spec.rb +1 -20
- data/spec/complete_spec.rb +1 -23
- data/spec/config_spec.rb +1 -1
- data/spec/spec_helper.rb +4 -5
- data/test.sh +29 -25
- metadata +92 -212
- data/.githooks/pre_commit/run_specs.rb +0 -23
- data/Dockerfile +0 -15
- data/Dockerfile.fpm +0 -18
- data/Dockerfile.publish +0 -12
- data/Dockerfile.standalone +0 -33
- data/Dockerfile.validate-packaging +0 -9
- data/VERSION +0 -1
- data/acceptance-features/audit/audit_event_send.feature +0 -107
- data/acceptance-features/audit/fetch.feature +0 -16
- data/acceptance-features/audit/send.feature +0 -51
- data/acceptance-features/authentication/authenticate.feature +0 -10
- data/acceptance-features/authentication/login.feature +0 -12
- data/acceptance-features/authentication/logout.feature +0 -13
- data/acceptance-features/authorization/resource/annotate.feature +0 -35
- data/acceptance-features/authorization/resource/check.feature +0 -24
- data/acceptance-features/authorization/resource/create.feature +0 -21
- data/acceptance-features/authorization/resource/deny.feature +0 -12
- data/acceptance-features/authorization/resource/give.feature +0 -24
- data/acceptance-features/authorization/resource/permit.feature +0 -20
- data/acceptance-features/authorization/resource/permitted_roles.feature +0 -16
- data/acceptance-features/authorization/resource/show.feature +0 -28
- data/acceptance-features/authorization/role/create.feature +0 -13
- data/acceptance-features/authorization/role/exists.feature +0 -19
- data/acceptance-features/authorization/role/grant_to.feature +0 -21
- data/acceptance-features/authorization/role/graph.feature +0 -57
- data/acceptance-features/authorization/role/members.feature +0 -23
- data/acceptance-features/authorization/role/memberships.feature +0 -27
- data/acceptance-features/bootstrap.feature +0 -13
- data/acceptance-features/conjurenv/check.feature +0 -21
- data/acceptance-features/conjurenv/run.feature +0 -10
- data/acceptance-features/directory/group/create.feature +0 -20
- data/acceptance-features/directory/group/retire.feature +0 -54
- data/acceptance-features/directory/host/create.feature +0 -23
- data/acceptance-features/directory/host/retire.feature +0 -6
- data/acceptance-features/directory/hostfactory/create.feature +0 -28
- data/acceptance-features/directory/hostfactory/tokens.feature +0 -16
- data/acceptance-features/directory/layer/create.feature +0 -10
- data/acceptance-features/directory/layer/hosts-add.feature +0 -9
- data/acceptance-features/directory/layer/hosts-remove.feature +0 -10
- data/acceptance-features/directory/layer/retire.feature +0 -43
- data/acceptance-features/directory/user/create.feature +0 -23
- data/acceptance-features/directory/user/retire.feature +0 -6
- data/acceptance-features/directory/variable/create.feature +0 -14
- data/acceptance-features/directory/variable/retire.feature +0 -17
- data/acceptance-features/dsl/policy_owner.feature +0 -45
- data/acceptance-features/dsl/resource_owner.feature +0 -17
- data/acceptance-features/dsl/retire.feature +0 -15
- data/acceptance-features/global-privilege/elevate.feature +0 -20
- data/acceptance-features/global-privilege/reveal.privilege +0 -20
- data/acceptance-features/pubkeys/add.feature +0 -22
- data/acceptance-features/pubkeys/delete.feature +0 -9
- data/acceptance-features/pubkeys/names.feature +0 -26
- data/acceptance-features/pubkeys/show.feature +0 -27
- data/acceptance-features/step_definitions/cli_steps.rb +0 -57
- data/acceptance-features/step_definitions/graph_steps.rb +0 -22
- data/acceptance-features/step_definitions/user_steps.rb +0 -51
- data/acceptance-features/support/env.rb +0 -23
- data/acceptance-features/support/hooks.rb +0 -178
- data/acceptance-features/support/world.rb +0 -176
- data/acceptance-features/trusted_proxies.feature +0 -82
- data/bin/conjurize +0 -26
- data/bin/jsonfield +0 -70
- data/build-standalone +0 -6
- data/deprecations.sh +0 -38
- data/features/conjurize.feature +0 -134
- data/features/dsl_context.feature +0 -36
- data/features/dsl_host_create.feature +0 -11
- data/features/dsl_ownership.feature +0 -30
- data/features/dsl_permission.feature +0 -45
- data/features/dsl_resource_create.feature +0 -23
- data/features/dsl_role_create.feature +0 -11
- data/features/dsl_user_create.feature +0 -23
- data/features/jsonfield.feature +0 -49
- data/features/role_graph.feature +0 -58
- data/features/step_definitions/conjurize_steps.rb +0 -5
- data/features/step_definitions/dsl_steps.rb +0 -52
- data/features/support/conjur.conf +0 -6
- data/lib/conjur/command/assets.rb +0 -121
- data/lib/conjur/command/audit.rb +0 -155
- data/lib/conjur/command/bootstrap.rb +0 -129
- data/lib/conjur/command/dsl_command.rb +0 -75
- data/lib/conjur/command/elevate.rb +0 -76
- data/lib/conjur/command/field.rb +0 -45
- data/lib/conjur/command/groups.rb +0 -208
- data/lib/conjur/command/ids.rb +0 -34
- data/lib/conjur/command/layers.rb +0 -211
- data/lib/conjur/command/ldapsync.rb +0 -118
- data/lib/conjur/command/rspec/audit_helpers.rb +0 -68
- data/lib/conjur/command/rubydsl.rb +0 -93
- data/lib/conjur/command/script.rb +0 -48
- data/lib/conjur/command/server.rb +0 -67
- data/lib/conjur/conjurize.rb +0 -71
- data/lib/conjur/conjurize/script.rb +0 -150
- data/lib/conjur/dsl/runner.rb +0 -273
- data/publish-deb.sh +0 -6
- data/push-image +0 -29
- data/spec/command/assets_spec.rb +0 -115
- data/spec/command/audit_spec.rb +0 -376
- data/spec/command/elevate_spec.rb +0 -28
- data/spec/command/env_spec.rb +0 -168
- data/spec/command/groups_spec.rb +0 -77
- data/spec/command/host_factories_spec.rb +0 -38
- data/spec/command/layers_spec.rb +0 -35
- data/spec/command/ldapsync_spec.rb +0 -28
- data/spec/command/rubydsl_spec.rb +0 -63
- data/spec/command/variable_expiration_spec.rb +0 -164
- data/spec/command/variables_spec.rb +0 -192
- data/spec/conjurize/script_spec.rb +0 -62
- data/spec/conjurize_spec.rb +0 -70
- data/spec/dsl/runner_spec.rb +0 -93
- data/spec/env_spec.rb +0 -214
@@ -1,51 +0,0 @@
|
|
1
|
-
Given(/^I login as a new user$/) do
|
2
|
-
@username_index ||= 0
|
3
|
-
username = %w(alice bob charles dave edward)[@username_index]
|
4
|
-
raise "I'm out of usernames!" unless username
|
5
|
-
@username_index += 1
|
6
|
-
@username = "#{username}@$ns"
|
7
|
-
step %Q(I login as new user "#{@username}")
|
8
|
-
end
|
9
|
-
|
10
|
-
Given(/^I create a new user named "(.*?)"$/) do |username|
|
11
|
-
step "I successfully run `conjur user create --as-role user:admin@#{namespace} #{username}`"
|
12
|
-
|
13
|
-
user_info = JSON.parse(last_command_started.stdout)
|
14
|
-
save_password username, user_info['api_key']
|
15
|
-
end
|
16
|
-
|
17
|
-
Given(/^I create a new host with id "(.*?)"$/) do |hostid|
|
18
|
-
step "I successfully run `conjur host create #{namespace}/monitoring/server`"
|
19
|
-
host = JSON.parse(last_json)
|
20
|
-
@host_id = host['id']
|
21
|
-
@host_api_key = host['api_key']
|
22
|
-
end
|
23
|
-
|
24
|
-
Given(/^I login as the new host/) do
|
25
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "host/#{@host_id}")
|
26
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{@host_api_key}")
|
27
|
-
end
|
28
|
-
|
29
|
-
Given(/^I login as new user "(.*?)"$/) do |username|
|
30
|
-
step %Q(I create a new user named "#{username}")
|
31
|
-
step %Q(I login as "#{username}")
|
32
|
-
end
|
33
|
-
|
34
|
-
Given(/^I login as "(.*?)"$/) do |username|
|
35
|
-
password = find_password(username)
|
36
|
-
|
37
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "#{username}")
|
38
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{password}")
|
39
|
-
end
|
40
|
-
|
41
|
-
Then(/^I(?: can)? type and confirm a new password/) do
|
42
|
-
@password = SecureRandom.hex(12)
|
43
|
-
step %Q(I type "#{@password}")
|
44
|
-
step %Q(I type "#{@password}")
|
45
|
-
step "the exit status should be 0"
|
46
|
-
end
|
47
|
-
|
48
|
-
When(/^I enter the password/) do
|
49
|
-
raise "No current password" unless @password
|
50
|
-
step %Q(I type "#{@password}")
|
51
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "aruba/cucumber"
|
2
|
-
require "json_spec/cucumber"
|
3
|
-
require 'cucumber-api'
|
4
|
-
require 'addressable/uri'
|
5
|
-
|
6
|
-
$LOAD_PATH.unshift File.expand_path('../..', File.dirname(__FILE__))
|
7
|
-
|
8
|
-
# Overwrite cucumber-api's resolve function so it will use the scheme
|
9
|
-
# and host from ENV['CONJUR_APPLIANCE_URL'] if url doesn't already
|
10
|
-
# have a host.
|
11
|
-
$orig_resolve = self.method(:resolve)
|
12
|
-
def resolve url
|
13
|
-
# disable cucumber-api's ill-considered cache. Re-authenticate in
|
14
|
-
# case it (cucumber-api) wiped out the headers
|
15
|
-
$cache = {}
|
16
|
-
add_user_auth_header
|
17
|
-
url = Addressable::URI.parse(url)
|
18
|
-
unless url.host
|
19
|
-
conjur_url = Addressable::URI.parse(Conjur.configuration.appliance_url)
|
20
|
-
url.merge!(:scheme => conjur_url.scheme, :host => conjur_url.host)
|
21
|
-
end
|
22
|
-
$orig_resolve.call(url.to_s)
|
23
|
-
end
|
@@ -1,178 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'conjur/api'
|
3
|
-
require 'conjur/cli'
|
4
|
-
require 'conjur/authn'
|
5
|
-
|
6
|
-
netrc = Conjur::Authn.netrc
|
7
|
-
username, password = Conjur::Authn.get_credentials
|
8
|
-
raise "Not logged in to Conjur" unless username && password
|
9
|
-
puts "Performing acceptance tests as root-ish user '#{username}'"
|
10
|
-
|
11
|
-
Aruba.configure do |config|
|
12
|
-
config.exit_timeout = 30
|
13
|
-
config.io_wait_timeout = 2
|
14
|
-
end
|
15
|
-
|
16
|
-
Before('@conjurapi-log') do
|
17
|
-
set_env 'CONJURAPI_LOG', 'stderr'
|
18
|
-
end
|
19
|
-
|
20
|
-
Before do
|
21
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "#{username}")
|
22
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{password}")
|
23
|
-
|
24
|
-
@admin_api = Conjur::Authn.connect
|
25
|
-
@test_user = admin_api.create_user "admin@#{namespace}", ownerid: "#{Conjur.configuration.account}:user:#{username}"
|
26
|
-
|
27
|
-
@security_admin = admin_api.create_group [ namespace, "security_admin" ].join('/')
|
28
|
-
@security_admin.add_member test_user, admin_option: true
|
29
|
-
|
30
|
-
JsonSpec.memorize "MY_ROLEID", %Q("#{test_user.roleid}")
|
31
|
-
JsonSpec.memorize "NAMESPACE", namespace
|
32
|
-
|
33
|
-
admin_api.group("pubkeys-1.0/key-managers").add_member @security_admin
|
34
|
-
admin_api.resource('!:!:conjur').permit 'elevate', test_user, grant_option: true
|
35
|
-
admin_api.resource('!:!:conjur').permit 'reveal', test_user, grant_option: true
|
36
|
-
|
37
|
-
admin_api.create_user "attic@#{namespace}"
|
38
|
-
|
39
|
-
# Set up the environment so the CLI will authenticate
|
40
|
-
# correctly. Note that the API caches credentials, so these
|
41
|
-
# variables won't have any effect on future calls to
|
42
|
-
# Conjur::Authn.connect
|
43
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_LOGIN" to "#{test_user.login}")
|
44
|
-
step %Q(I set the environment variable "CONJUR_AUTHN_API_KEY" to "#{test_user.api_key}")
|
45
|
-
end
|
46
|
-
|
47
|
-
After do
|
48
|
-
if admin_api
|
49
|
-
admin_api.group("pubkeys-1.0/key-managers").remove_member @security_admin
|
50
|
-
admin_api = nil
|
51
|
-
namespace = nil
|
52
|
-
end
|
53
|
-
tempfiles.each { |tempfile| File.unlink(tempfile) unless tempfile.nil? }
|
54
|
-
end
|
55
|
-
|
56
|
-
require 'ostruct'
|
57
|
-
|
58
|
-
class MockAPI
|
59
|
-
attr_reader :things
|
60
|
-
|
61
|
-
def initialize
|
62
|
-
@things = {}
|
63
|
-
end
|
64
|
-
|
65
|
-
def thing(kind, id)
|
66
|
-
(@things[kind.to_sym] || []).find{|r| r.id == id}
|
67
|
-
end
|
68
|
-
|
69
|
-
def thing_like(kind, id_pattern)
|
70
|
-
(@things[kind.to_sym] || []).find{|r| id_pattern.match(r.id)}
|
71
|
-
end
|
72
|
-
|
73
|
-
def create_host(options = {})
|
74
|
-
id = options.delete(:id)
|
75
|
-
if id
|
76
|
-
host = thing(:host, id)
|
77
|
-
else
|
78
|
-
id = SecureRandom.uuid
|
79
|
-
end
|
80
|
-
host ||= create_thing(:host, id, options, role: true, api_key: true)
|
81
|
-
end
|
82
|
-
|
83
|
-
def create_user(id, options = {})
|
84
|
-
thing(:user, id) || create_thing(:user, id, options, role: true, api_key: true)
|
85
|
-
end
|
86
|
-
|
87
|
-
def create_variable(mime_type, kind)
|
88
|
-
create_thing(:user, SecureRandom.uuid, mime_type: mime_type, kind: kind)
|
89
|
-
end
|
90
|
-
|
91
|
-
def create_resource(id, options = {})
|
92
|
-
resource(id).tap do |resource|
|
93
|
-
resource.send(:"exists?=", true)
|
94
|
-
populate_options resource, options
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def create_role(id, options = {})
|
99
|
-
role(id).tap do |role|
|
100
|
-
role.send(:"exists?=", true)
|
101
|
-
populate_options role, options
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
[ :user, :host ].each do |kind|
|
106
|
-
define_method kind do |id|
|
107
|
-
thing(kind, id)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
def role(id)
|
112
|
-
raise "Role id must be a string" unless id.is_a?(String)
|
113
|
-
thing(:role, id) || create_thing(:role, id, { exists?: false }, role: true)
|
114
|
-
end
|
115
|
-
|
116
|
-
def resource(id)
|
117
|
-
raise "Resource id must be a string" unless id.is_a?(String)
|
118
|
-
thing(:resource, id) || create_thing(:resource, id, exists?: false)
|
119
|
-
end
|
120
|
-
|
121
|
-
protected
|
122
|
-
|
123
|
-
def create_thing(kind, id, options, kind_options = {})
|
124
|
-
thing = OpenStruct.new(kind: kind, id: id, exists?: true)
|
125
|
-
|
126
|
-
class << thing
|
127
|
-
def permit(privilege, role, options = {})
|
128
|
-
(self.permissions ||= []) << OpenStruct.new(privilege: privilege, role: role.id, grant_option: !!options[:grant_option])
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
if kind_options[:api_key]
|
133
|
-
thing.api_key = SecureRandom.uuid
|
134
|
-
end
|
135
|
-
if kind_options[:role]
|
136
|
-
thing.roleid = id
|
137
|
-
class << thing
|
138
|
-
def can(privilege, resource, options = {})
|
139
|
-
resource.permit privilege, self, options
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
populate_options(thing, options)
|
145
|
-
|
146
|
-
store_thing kind, thing
|
147
|
-
|
148
|
-
thing
|
149
|
-
end
|
150
|
-
|
151
|
-
def populate_options(thing, options)
|
152
|
-
options.each do |k,v|
|
153
|
-
thing.send("#{k}=", v)
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
def store_thing(kind, thing)
|
158
|
-
(things[kind] ||= []) << thing
|
159
|
-
end
|
160
|
-
end
|
161
|
-
|
162
|
-
Before("@dsl") do
|
163
|
-
puts "Using MockAPI"
|
164
|
-
puts "Using account 'cucumber'"
|
165
|
-
|
166
|
-
require 'conjur/api'
|
167
|
-
require 'conjur/config'
|
168
|
-
require 'conjur/dsl/runner'
|
169
|
-
|
170
|
-
Conjur.stub(:env).and_return "ci"
|
171
|
-
Conjur.stub(:stack).and_return "ci"
|
172
|
-
Conjur.stub(:account).and_return "cucumber"
|
173
|
-
|
174
|
-
Conjur::Core::API.stub(:conjur_account).and_return 'cucumber'
|
175
|
-
@mock_api ||= MockAPI.new
|
176
|
-
Conjur::DSL::Runner.any_instance.stub(:api).and_return @mock_api
|
177
|
-
end
|
178
|
-
|
@@ -1,176 +0,0 @@
|
|
1
|
-
require 'aruba/api'
|
2
|
-
require 'conjur/api'
|
3
|
-
|
4
|
-
module ConjurCLIWorld
|
5
|
-
include Aruba::Api
|
6
|
-
|
7
|
-
attr_accessor :admin_api, :namespace, :test_user, :headers
|
8
|
-
|
9
|
-
def last_json
|
10
|
-
process_cmd last_command_started.stdout
|
11
|
-
end
|
12
|
-
|
13
|
-
def passwords
|
14
|
-
@passwords ||= {}
|
15
|
-
end
|
16
|
-
|
17
|
-
def save_password username, password
|
18
|
-
raise "Password for #{username} not found" if password.blank?
|
19
|
-
raise "Found existing password for user '#{username}'" if passwords[username]
|
20
|
-
passwords[username] = password
|
21
|
-
end
|
22
|
-
|
23
|
-
def find_password username
|
24
|
-
passwords[username] or raise "No password for user '#{username}'"
|
25
|
-
end
|
26
|
-
|
27
|
-
def find_or_create_password(username)
|
28
|
-
unless password = passwords[username]
|
29
|
-
password = passwords[username] = SecureRandom.hex(12)
|
30
|
-
end
|
31
|
-
password
|
32
|
-
end
|
33
|
-
|
34
|
-
def admin_role
|
35
|
-
admin_api.current_role.role_id
|
36
|
-
end
|
37
|
-
|
38
|
-
def random_hex nbytes = 12
|
39
|
-
@random ||= Random.new
|
40
|
-
@random.bytes(nbytes).unpack('h*').first
|
41
|
-
end
|
42
|
-
|
43
|
-
def namespace
|
44
|
-
@namespace ||= random_hex
|
45
|
-
end
|
46
|
-
|
47
|
-
# Aruba's method
|
48
|
-
def run(cmd, *args)
|
49
|
-
# it's a thunk now so it should be returned. puts can be added back as block if we want to
|
50
|
-
super process_cmd(cmd), *args
|
51
|
-
end
|
52
|
-
|
53
|
-
# Substitute the namespace for marker $ns
|
54
|
-
def sanitize_text string
|
55
|
-
string = super
|
56
|
-
string.gsub("$ns", namespace)
|
57
|
-
end
|
58
|
-
|
59
|
-
def get_process(wanted)
|
60
|
-
super wanted.gsub("$ns", namespace)
|
61
|
-
end
|
62
|
-
|
63
|
-
def tempfiles
|
64
|
-
@tempfiles||=[]
|
65
|
-
end
|
66
|
-
|
67
|
-
def headers
|
68
|
-
@headers ||= {}
|
69
|
-
end
|
70
|
-
|
71
|
-
def add_user_auth_header
|
72
|
-
return if headers['Authorization']
|
73
|
-
|
74
|
-
token = Conjur::API.authenticate(test_user.login, test_user.api_key)
|
75
|
-
headers.merge!(
|
76
|
-
'Authorization' => %Q{Token token="#{Base64.strict_encode64(token.to_json)}"}
|
77
|
-
)
|
78
|
-
end
|
79
|
-
|
80
|
-
protected
|
81
|
-
|
82
|
-
def process_cmd(cmd)
|
83
|
-
cmd = cmd.dup
|
84
|
-
cmd.gsub!("$ns", namespace)
|
85
|
-
cmd.gsub!("$pubkeys_url", Conjur.configuration.pubkeys_url)
|
86
|
-
|
87
|
-
JsonSpec.memory.each do |k,v|
|
88
|
-
cmd.gsub!("%{#{k}}", v)
|
89
|
-
end
|
90
|
-
cmd
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
module ConjurWorld
|
95
|
-
def last_json
|
96
|
-
last_stdout
|
97
|
-
end
|
98
|
-
|
99
|
-
def last_stdout
|
100
|
-
raise "No commands have been run" unless last_cmd
|
101
|
-
stdout_from last_cmd
|
102
|
-
end
|
103
|
-
|
104
|
-
attr_accessor :last_cmd
|
105
|
-
|
106
|
-
def account
|
107
|
-
Conjur::Core::API.conjur_account
|
108
|
-
end
|
109
|
-
|
110
|
-
def role_kind
|
111
|
-
@role_kind ||= "cli-cukes"
|
112
|
-
end
|
113
|
-
|
114
|
-
def role_id_map
|
115
|
-
@role_id_map ||= {}
|
116
|
-
end
|
117
|
-
|
118
|
-
def extract_filtered_graph json
|
119
|
-
graph = JSON.parse(json.to_s)
|
120
|
-
case graph
|
121
|
-
when Hash then filter_hash_graph(graph)
|
122
|
-
when Array then filter_array_graph(graph)
|
123
|
-
else raise "WTF: graph was #{graph.class}?"
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
def filter_hash_graph graph
|
128
|
-
allowed = role_id_map.values
|
129
|
-
edges = graph['graph']
|
130
|
-
filtered = edges.select do |edge|
|
131
|
-
allowed.member?(edge['parent']) and allowed.member?(edge['child'])
|
132
|
-
end
|
133
|
-
{'graph' => filtered}
|
134
|
-
end
|
135
|
-
|
136
|
-
def filter_array_graph graph
|
137
|
-
allowed = role_id_map.values
|
138
|
-
graph.select do |edge|
|
139
|
-
edge.all?{|v| allowed.member?(v)}
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
def graph edges
|
144
|
-
# generate roles
|
145
|
-
edges.flatten.uniq.each do |role_id|
|
146
|
-
role_id_map[role_id] = expanded = expand_role_id(role_id)
|
147
|
-
run_command "conjur role create '#{expanded}'"
|
148
|
-
end
|
149
|
-
|
150
|
-
# generate memberships
|
151
|
-
edges.each do |parent, child|
|
152
|
-
run_command "conjur role grant_to #{expand_role_id(parent)} #{expand_role_id(child)}"
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
def run_command cmd
|
157
|
-
step "I successfully run " + '`' + cmd + '`'
|
158
|
-
end
|
159
|
-
|
160
|
-
def expand_role_id role_id
|
161
|
-
"#{account}:#{role_kind}:#{prepend_namespace role_id}"
|
162
|
-
end
|
163
|
-
|
164
|
-
def prepend_namespace id
|
165
|
-
"#{namespace}-#{id}"
|
166
|
-
end
|
167
|
-
|
168
|
-
def expand_roles string
|
169
|
-
role_id_map.each do |role, expanded|
|
170
|
-
string.gsub! role, expanded
|
171
|
-
end
|
172
|
-
string
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
World(ConjurWorld, ConjurCLIWorld)
|
@@ -1,82 +0,0 @@
|
|
1
|
-
Feature: Conjur services support trusted proxies
|
2
|
-
|
3
|
-
As an administrator of the Conjur Appliance, I want to be able to
|
4
|
-
specify CIDRs for machines that should be regarded as trusted
|
5
|
-
proxies. IP addresses that match those CIDRs can be regarded as
|
6
|
-
coming from localhost. Other addresses should not be remapped (even
|
7
|
-
if those addresses are non-routable), and so will appear in audit
|
8
|
-
events and be used to validate CIDR restrictions (e.g. on
|
9
|
-
hostfactory tokens).
|
10
|
-
|
11
|
-
Scenario: authn supports trusted proxies for CIDR restrictions
|
12
|
-
Given I set the JSON request body to:
|
13
|
-
"""
|
14
|
-
{
|
15
|
-
"login": "restricted@$ns",
|
16
|
-
"password": "restricted",
|
17
|
-
"ownerid": "cucumber:user:admin@$ns",
|
18
|
-
"cidr": ["192.168.0.0/24"]
|
19
|
-
}
|
20
|
-
"""
|
21
|
-
And I send a POST request to "/api/users"
|
22
|
-
And the response status should be "201"
|
23
|
-
Given I send "text/plain" and accept JSON
|
24
|
-
And I set the request body to "restricted"
|
25
|
-
When I send a POST request forwarded from "192.168.0.1" to "/api/authn/users/restricted@$ns/authenticate"
|
26
|
-
Then the response status should be "200"
|
27
|
-
|
28
|
-
Scenario: authz supports trusted proxies
|
29
|
-
Given I send a PUT request forwarded from "192.168.0.1" to "/api/authz/cucumber/resources/test/$ns/resource?acting_as=$user_role"
|
30
|
-
And the response status should be "204"
|
31
|
-
When I successfully run `conjur audit resource test:$ns/resource`
|
32
|
-
Then the JSON response at "request/ip" should be "192.168.0.1"
|
33
|
-
|
34
|
-
Scenario: core supports trusted proxies
|
35
|
-
Given I set the JSON request body to:
|
36
|
-
"""
|
37
|
-
{
|
38
|
-
"id": "$ns/var",
|
39
|
-
"kind": "password",
|
40
|
-
"mime_type": "text/plain"
|
41
|
-
}
|
42
|
-
"""
|
43
|
-
And I send a POST request forwarded from "192.168.0.1" to "/api/variables"
|
44
|
-
And the response status should be "201"
|
45
|
-
When I successfully run `conjur audit resource variable:$ns/var`
|
46
|
-
Then the JSON response at "request/ip" should be "192.168.0.1"
|
47
|
-
|
48
|
-
Scenario: expiration supports trusted proxies
|
49
|
-
Given I successfully run `conjur variable create $ns_expiration_var value`
|
50
|
-
And I send a GET request forwarded from "192.168.0.1" to "/api/variables/$ns_expiration_var/value"
|
51
|
-
And the response status should be "200"
|
52
|
-
When I get the audit event for the resource "cucumber:variable:$ns_expiration_var" with action "check"
|
53
|
-
Then the audit event should show the request from "192.168.0.1"
|
54
|
-
|
55
|
-
Scenario: host-factory supports trusted proxies when creating hostfactories
|
56
|
-
Given I successfully run `conjur layer create --as-role $user_role $ns/layer`
|
57
|
-
When I send a POST request forwarded from "192.168.0.1" to "/api/host_factories" with:
|
58
|
-
| id | roleid | ownerid | layers[] |
|
59
|
-
| $ns/hf | $user_role | $user_role | $ns/layer |
|
60
|
-
|
61
|
-
And the response status should be "201"
|
62
|
-
And I successfully run `conjur audit resource host_factory:$ns/hf`
|
63
|
-
Then the JSON response at "request/ip" should be "192.168.0.1"
|
64
|
-
|
65
|
-
Scenario: hostfactory supports trusted proxies when creating hosts
|
66
|
-
Given I successfully run `conjur layer create --as-role $user_role $ns/layer`
|
67
|
-
And I successfully run `conjur hostfactory create --as-role $user_role --layer $ns/layer $ns/hf`
|
68
|
-
And I create a hostfactory token for "$ns/hf" with CIDR "192.168.0.0/16"
|
69
|
-
When I use the hostfactory token from "192.168.0.1" to create host "$ns/host"
|
70
|
-
And I get the audit event for the resource "cucumber:host:$ns/host" with action "create"
|
71
|
-
Then the audit event should show the request from "192.168.0.1"
|
72
|
-
|
73
|
-
Scenario: hostfactory supports trusted proxies when validating token CIDR restrictions
|
74
|
-
Given I successfully run `conjur layer create --as-role $user_role $ns/layer`
|
75
|
-
And I successfully run `conjur hostfactory create --as-role $user_role --layer $ns/layer $ns/hf`
|
76
|
-
And I create a hostfactory token for "$ns/hf" with CIDR "192.168.0.0/16"
|
77
|
-
Then I can use the hostfactory token from "192.168.0.1" to create host "$ns/host1"
|
78
|
-
|
79
|
-
Scenario: pubkeys supports trusted proxies
|
80
|
-
Given I create a pubkey for "pubkeys_user@$ns" from "192.168.0.1" with "ssh-rsa foobar pubkeys_user@host"
|
81
|
-
When I get the audit event for the pubkey variable with action "create"
|
82
|
-
Then the audit event should show the request from "192.168.0.1"
|