cf-uaac 3.13.1 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8ef367062c3e28c384a318cbf086099558e965a4
4
- data.tar.gz: 2cc9ad180ad1a8ccdb88eab48191cc8931bd336c
2
+ SHA256:
3
+ metadata.gz: 8ec28aaefed5216eceb8c2665fd861167475f4b02202c0f7a432ded556374b02
4
+ data.tar.gz: aa68a4e5bdced51b1a049f8cad96237eec7784c596dfc51f77de0c5dd0a3fdc8
5
5
  SHA512:
6
- metadata.gz: c56c0743dbede318336371e6d731d0f6d895a949f41905bc60cd492348a8ae818b21cf4f0f7cbb85ebc5ae3a5b46195c44e674315a074fa97d3df55325adbfc6
7
- data.tar.gz: ade14cd1d7aeec495397587b486327cf046794e68c8a5a902005b25f0124b8db7c9d50e966f828bcf3fe390ee0c15bc4e22c75a4e52de6481f1249598a50c17a
6
+ metadata.gz: f5e0299e7af1702bd5ec78da39eb6d731a1eda5d1458c5ff564f6a0b141877ee9e84351fa107984719c77be3e49ca4323967222ddff7dc08f8e24daa74f725dc
7
+ data.tar.gz: 19999aa17a59d217da5e01cdef536834d4b10529a4bc860b5ddbdac07637336ebf594b5d18e18dd93256b2cdb3607067ea283c8f687d679c75c627391721f545
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "11:00"
8
+ open-pull-requests-limit: 10
9
+ allow:
10
+ - dependency-type: direct
11
+ - dependency-type: indirect
data/.travis.yml CHANGED
@@ -5,6 +5,6 @@ before_install:
5
5
  - gem install bundler
6
6
 
7
7
  rvm:
8
- - 2.2.7
9
- - 2.3.4
10
- - 2.4.1
8
+ - 2.7
9
+ - 2.6
10
+ - 2.5
data/bin/uaac CHANGED
@@ -15,4 +15,6 @@
15
15
 
16
16
  $:.unshift File.expand_path File.join __FILE__, '..', '..', 'lib'
17
17
  require 'uaac_cli'
18
- exit CF::UAA::Cli.configure("#{ENV['HOME']}/.uaac.yml").run ? 0 : 1
18
+ home = ENV['UAAC_HOME']
19
+ home = ENV['HOME'] if home.nil? || home.empty?
20
+ exit CF::UAA::Cli.configure("#{home}/.uaac.yml").run ? 0 : 1
data/cf-uaac.gemspec CHANGED
@@ -34,16 +34,15 @@ Gem::Specification.new do |s|
34
34
 
35
35
  # dependencies
36
36
  s.add_runtime_dependency 'cf-uaa-lib', '~> 3.11'
37
- s.add_development_dependency 'bundler', '~> 1.14'
38
- s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.1'
39
- s.add_development_dependency 'rspec', '~> 2.14', '>= 2.14.1'
40
- s.add_development_dependency 'simplecov', '~> 0.8.2'
37
+ s.add_development_dependency 'rake', '>= 10.3.1', '~> 13.0'
38
+ s.add_development_dependency 'rspec', '>= 2.14.1', '~> 3.9'
39
+ s.add_development_dependency 'simplecov', '~> 0.21.2'
41
40
  s.add_development_dependency 'simplecov-rcov', '~> 0.2.3'
42
41
  s.add_development_dependency 'ci_reporter', '~> 1.9', '>= 1.9.2'
43
42
  s.add_runtime_dependency 'highline', '~> 1.6', '>= 1.6.21'
44
43
  s.add_runtime_dependency 'eventmachine', '~> 1.0', '>= 1.0.3'
45
44
  s.add_runtime_dependency 'launchy', '~> 2.4', '>= 2.4.2'
46
45
  s.add_runtime_dependency 'em-http-request', '~> 1.1', '>= 1.1.2'
47
- s.add_runtime_dependency 'json_pure', '~> 1.8', '>= 1.8.1'
48
- s.add_runtime_dependency 'rack', '~> 1.5', '>= 1.5.2'
46
+ s.add_runtime_dependency 'json_pure', '>= 1.8.1', '< 3.0'
47
+ s.add_runtime_dependency 'rack', '>= 1.5.2', '< 3.0'
49
48
  end
@@ -88,11 +88,10 @@ class CommonCli < Topic
88
88
  def scim_common_list(type, filter)
89
89
  pp scim_request { |sr|
90
90
  query = { attributes: opts[:attrs], filter: filter }
91
- info = nil
92
- if type == :user
93
- info = sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count]))
91
+ info = if type == :user
92
+ sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count]))
94
93
  else
95
- info = opts[:start] || opts[:count] ?
94
+ opts[:start] || opts[:count] ?
96
95
  sr.query(type, query.merge!(startIndex: opts[:start], count: opts[:count])):
97
96
  sr.all_pages(type, query)
98
97
  end
@@ -109,21 +108,24 @@ class CommonCli < Topic
109
108
  info = scim.all_pages(type, query)
110
109
  raise BadResponse unless info.is_a?(Array)
111
110
  raise NotFound if info.length == 0
112
- if info.length >= 2
111
+ chosen_info = if info.length >= 2
112
+ say 'Select an origin:'
113
113
  info.each_with_index do |i, idx|
114
+ say "#{idx + 1}. #{i['origin']}"
114
115
  end
115
116
 
116
117
  choice = @highline.ask("Select user: ").to_i
117
118
  if choice > info.length || choice <= 0
118
- raise ArgumentError 'bad input, klugscheisser'
119
+ raise ArgumentError.new('bad input')
119
120
  end
120
- info = info[choice - 1]
121
+ info[choice - 1]
121
122
  else
122
- info = info[0]
123
+ info[0]
123
124
  end
124
125
 
126
+
125
127
  # when getting whole object, handle case of UAA < 1.3 which did not return meta attr from query
126
- attrs || !info["id"] || info["meta"] ? info : scim.get(type, info["id"])
128
+ attrs || !chosen_info["id"] || chosen_info["meta"] ? chosen_info : scim.get(type, chosen_info["id"])
127
129
  end
128
130
 
129
131
  def scim_get_object(scim, type, name, attrs = nil)
@@ -46,14 +46,14 @@ class Config
46
46
  exit 1
47
47
  end
48
48
  else # file doesn't exist, make sure we can write it now
49
- File.open(@config_file, 'w') { |f| f.write("--- {}\n\n") }
49
+ self.write_file(@config_file, "--- {}\n\n")
50
50
  end
51
51
  Util.hash_keys!(@config, :sym)
52
52
  @context = current_subhash(@config[@target][:contexts]) if @target = current_subhash(@config)
53
53
  end
54
54
 
55
55
  def self.save
56
- File.open(@config_file, 'w') { |f| YAML.dump(Util.hash_keys(@config, :str), f) } if @config_file
56
+ self.write_file(@config_file, YAML.dump(Util.hash_keys(@config, :str))) if @config_file
57
57
  true
58
58
  end
59
59
 
@@ -134,6 +134,11 @@ class Config
134
134
  # methods below here are not intended to be part of the public interface
135
135
  private
136
136
 
137
+ def self.write_file(filename, content)
138
+ File.open(filename, 'w') { |f| f.write content }
139
+ File.chmod(0600, filename)
140
+ end
141
+
137
142
  def self.current_subhash(hash)
138
143
  return unless hash
139
144
  key = nil
data/lib/uaa/cli/group.rb CHANGED
@@ -145,7 +145,9 @@ class GroupCli < CommonCli
145
145
  group = scim_get_object(scim, :group, gname(name))
146
146
 
147
147
  old_members = (group['members'] || [])
148
- new_members = find_members(scim, members)
148
+ new_members = find_members(scim, members).map do |member|
149
+ member.merge('origin' => 'uaa')
150
+ end
149
151
 
150
152
  unless new_members.size == members.size
151
153
  raise 'not all users found, none added'
@@ -183,25 +185,6 @@ class GroupCli < CommonCli
183
185
  'success'
184
186
  end
185
187
 
186
- def update_members(scim, name, attr, users, add = true)
187
- group = scim_get_object(scim, :group, gname(name))
188
- old_ids = id_set(group[attr] || [])
189
- new_ids = id_set(scim.ids(:user, *users))
190
- if add
191
- raise 'not all users found, none added' unless new_ids.size == users.size
192
- group[attr] = (old_ids + new_ids).to_a
193
- raise 'no new users given' unless group[attr].size > old_ids.size
194
- else
195
- raise 'not all users found, none deleted' unless new_ids.size == users.size
196
- group[attr] = (old_ids - new_ids).to_a
197
- raise 'no existing users to delete' unless group[attr].size < old_ids.size
198
- group.delete(attr) if group[attr].empty?
199
- end
200
-
201
- scim.put(:group, group)
202
- 'success'
203
- end
204
-
205
188
  desc "member add [name] [users...]", "add members to a group" do |name, *users|
206
189
  pp scim_request { |scim| add_members(scim, name, users) }
207
190
  end
@@ -209,23 +192,6 @@ class GroupCli < CommonCli
209
192
  desc "member delete [name] [users...]", "remove members from a group" do |name, *users|
210
193
  pp scim_request { |scim| delete_members(scim, name, users) }
211
194
  end
212
-
213
- desc "group reader add [name] [users...]", "add users who can read the members" do |name, *users|
214
- pp scim_request { |scim| update_members(scim, name, "readers", users) }
215
- end
216
-
217
- desc "group reader delete [name] [users...]", "delete users who can read members" do |name, *users|
218
- pp scim_request { |scim| update_members(scim, name, "readers", users, false) }
219
- end
220
-
221
- desc "group writer add [name] [users...]", "add users who can modify group" do |name, *users|
222
- pp scim_request { |scim| update_members(scim, name, "writers", users) }
223
- end
224
-
225
- desc "group writer delete [name] [users...]", "remove user who can modify group" do |name, *users|
226
- pp scim_request { |scim| update_members(scim, name, "writers", users, false) }
227
- end
228
-
229
195
  private
230
196
 
231
197
  def is_natural_number?(input)
data/lib/uaa/cli/token.rb CHANGED
@@ -88,7 +88,7 @@ class TokenCli < CommonCli
88
88
 
89
89
  def issuer_request(client_id, secret = nil)
90
90
  update_target_info
91
- yield TokenIssuer.new(Config.target.to_s, client_id, secret,
91
+ yield TokenIssuer.new(Config.target.to_s, CGI.escape(client_id), CGI.escape(secret),
92
92
  { token_target: Config.target_value(:token_endpoint),
93
93
  skip_ssl_validation: Config.target_value(:skip_ssl_validation),
94
94
  ssl_ca_file: Config.target_value(:ca_cert) })
@@ -14,6 +14,7 @@
14
14
  # Cloud Foundry namespace
15
15
  module CF
16
16
  module UAA
17
- CLI_VERSION = '3.13.1'
17
+ version_path = File.join( File.dirname(__FILE__), '../../../version.txt' )
18
+ CLI_VERSION = File.read(version_path)
18
19
  end
19
20
  end
data/lib/uaa/stub/uaa.rb CHANGED
@@ -15,6 +15,7 @@ require 'uaa'
15
15
  require 'uaa/stub/server'
16
16
  require 'uaa/stub/scim'
17
17
  require 'uaa/cli/version'
18
+ require 'cgi'
18
19
  require 'pp'
19
20
 
20
21
  module CF::UAA
@@ -168,6 +169,7 @@ class StubUAAConn < Stub::Base
168
169
  ah = basic_auth_header.split(' ')
169
170
  return unless ah[0] =~ /^basic$/i
170
171
  ah = Base64::strict_decode64(ah[1]).split(':')
172
+ ah = ah.map { |item| CGI::unescape(item) }
171
173
  client = server.scim.get_by_name(ah[0], :client)
172
174
  client if client && client[:client_secret] == ah[1]
173
175
  end
data/spec/group_spec.rb CHANGED
@@ -101,57 +101,6 @@ describe GroupCli do
101
101
  check_members
102
102
  end
103
103
 
104
- it "adds one reader to the group" do
105
- Cli.run("group reader add #{@test_group} #{@test_user}r").should be
106
- Cli.output.string.should include "success"
107
- end
108
-
109
- it "adds one writer to the group" do
110
- Cli.run("group writer add #{@test_group} #{@test_user}w").should be
111
- Cli.output.string.should include "success"
112
- end
113
-
114
- it "gets readers and writers in the group" do
115
- Cli.run("group get #{@test_group}").should be
116
- Cli.output.string.should be
117
- end
118
-
119
- it "reads members as a reader" do
120
- pending "Test not applicable in integration test runs" if ENV["UAA_CLIENT_TARGET"]
121
-
122
- Cli.run("token owner get #{@test_client} -s #{@test_secret} #{@test_user}r -p #{@test_pwd}").should be
123
- Cli.run("group get #{@test_group} -a memBers").should be
124
- ids = Cli.output.string.scan(/.*value:\s+([^\s]+)/).flatten
125
- @users.size.should == ids.size
126
- end
127
-
128
- it "can't write members as a reader" do
129
- Cli.run("token owner get #{@test_client} -s #{@test_secret} #{@test_user}r -p #{@test_pwd}").should be
130
- Cli.run("member add #{@test_group} #{@test_user}z").should_not be
131
- Cli.output.string.should include "access_denied"
132
- end
133
-
134
- it "adds a member as a writer" do
135
- pending "Test not applicable in integration test runs" if ENV["UAA_CLIENT_TARGET"]
136
-
137
- Cli.run "context #{@test_client}"
138
- Cli.run("user add #{@test_user}z -p #{@test_pwd} --email sam@example.com").should be
139
- @users << "#{@test_user}z"
140
- Cli.run("token owner get #{@test_client} -s #{@test_secret} #{@test_user}w -p #{@test_pwd}").should be
141
- Cli.run("member add #{@test_group} #{@test_user}z").should be
142
- Cli.run("group get #{@test_group} -a memBers").should be
143
- ids = Cli.output.string.scan(/.*value:\s+([^\s]+)/).flatten
144
- @users.size.should == ids.size
145
- # check_members
146
- end
147
-
148
- it "can't read members as a non-reader" do
149
- pending "real uaa still returns members even if user is not in readers list" unless @stub_uaa
150
- Cli.run("token owner get #{@test_client} -s #{@test_secret} #{@test_user}m -p #{@test_pwd}").should be
151
- Cli.run("group get #{@test_group}").should be_nil
152
- Cli.output.string.should include "NotFound"
153
- end
154
-
155
104
  it "deletes all members from a group" do
156
105
  Cli.run "context #{@test_client}"
157
106
  cmd = "member delete #{@test_group.downcase} "
data/version.txt ADDED
@@ -0,0 +1 @@
1
+ 4.3.0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-uaac
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.13.1
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Syer
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2017-07-28 00:00:00.000000000 Z
15
+ date: 2021-10-27 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: cf-uaa-lib
@@ -28,74 +28,60 @@ dependencies:
28
28
  - - "~>"
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3.11'
31
- - !ruby/object:Gem::Dependency
32
- name: bundler
33
- requirement: !ruby/object:Gem::Requirement
34
- requirements:
35
- - - "~>"
36
- - !ruby/object:Gem::Version
37
- version: '1.14'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - "~>"
43
- - !ruby/object:Gem::Version
44
- version: '1.14'
45
31
  - !ruby/object:Gem::Dependency
46
32
  name: rake
47
33
  requirement: !ruby/object:Gem::Requirement
48
34
  requirements:
49
- - - "~>"
50
- - !ruby/object:Gem::Version
51
- version: '10.3'
52
35
  - - ">="
53
36
  - !ruby/object:Gem::Version
54
37
  version: 10.3.1
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
55
41
  type: :development
56
42
  prerelease: false
57
43
  version_requirements: !ruby/object:Gem::Requirement
58
44
  requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '10.3'
62
45
  - - ">="
63
46
  - !ruby/object:Gem::Version
64
47
  version: 10.3.1
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: '13.0'
65
51
  - !ruby/object:Gem::Dependency
66
52
  name: rspec
67
53
  requirement: !ruby/object:Gem::Requirement
68
54
  requirements:
69
- - - "~>"
70
- - !ruby/object:Gem::Version
71
- version: '2.14'
72
55
  - - ">="
73
56
  - !ruby/object:Gem::Version
74
57
  version: 2.14.1
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.9'
75
61
  type: :development
76
62
  prerelease: false
77
63
  version_requirements: !ruby/object:Gem::Requirement
78
64
  requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '2.14'
82
65
  - - ">="
83
66
  - !ruby/object:Gem::Version
84
67
  version: 2.14.1
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '3.9'
85
71
  - !ruby/object:Gem::Dependency
86
72
  name: simplecov
87
73
  requirement: !ruby/object:Gem::Requirement
88
74
  requirements:
89
75
  - - "~>"
90
76
  - !ruby/object:Gem::Version
91
- version: 0.8.2
77
+ version: 0.21.2
92
78
  type: :development
93
79
  prerelease: false
94
80
  version_requirements: !ruby/object:Gem::Requirement
95
81
  requirements:
96
82
  - - "~>"
97
83
  - !ruby/object:Gem::Version
98
- version: 0.8.2
84
+ version: 0.21.2
99
85
  - !ruby/object:Gem::Dependency
100
86
  name: simplecov-rcov
101
87
  requirement: !ruby/object:Gem::Requirement
@@ -214,42 +200,42 @@ dependencies:
214
200
  name: json_pure
215
201
  requirement: !ruby/object:Gem::Requirement
216
202
  requirements:
217
- - - "~>"
218
- - !ruby/object:Gem::Version
219
- version: '1.8'
220
203
  - - ">="
221
204
  - !ruby/object:Gem::Version
222
205
  version: 1.8.1
206
+ - - "<"
207
+ - !ruby/object:Gem::Version
208
+ version: '3.0'
223
209
  type: :runtime
224
210
  prerelease: false
225
211
  version_requirements: !ruby/object:Gem::Requirement
226
212
  requirements:
227
- - - "~>"
228
- - !ruby/object:Gem::Version
229
- version: '1.8'
230
213
  - - ">="
231
214
  - !ruby/object:Gem::Version
232
215
  version: 1.8.1
216
+ - - "<"
217
+ - !ruby/object:Gem::Version
218
+ version: '3.0'
233
219
  - !ruby/object:Gem::Dependency
234
220
  name: rack
235
221
  requirement: !ruby/object:Gem::Requirement
236
222
  requirements:
237
- - - "~>"
238
- - !ruby/object:Gem::Version
239
- version: '1.5'
240
223
  - - ">="
241
224
  - !ruby/object:Gem::Version
242
225
  version: 1.5.2
226
+ - - "<"
227
+ - !ruby/object:Gem::Version
228
+ version: '3.0'
243
229
  type: :runtime
244
230
  prerelease: false
245
231
  version_requirements: !ruby/object:Gem::Requirement
246
232
  requirements:
247
- - - "~>"
248
- - !ruby/object:Gem::Version
249
- version: '1.5'
250
233
  - - ">="
251
234
  - !ruby/object:Gem::Version
252
235
  version: 1.5.2
236
+ - - "<"
237
+ - !ruby/object:Gem::Version
238
+ version: '3.0'
253
239
  description: Client command line tools for interacting with the CloudFoundry User
254
240
  Account and Authorization (UAA) server. The UAA is an OAuth2 Authorization Server
255
241
  so it can be used by webapps and command line apps to obtain access tokens to act
@@ -270,6 +256,7 @@ executables:
270
256
  extensions: []
271
257
  extra_rdoc_files: []
272
258
  files:
259
+ - ".github/dependabot.yml"
273
260
  - ".gitignore"
274
261
  - ".travis.yml"
275
262
  - ".yardopts"
@@ -311,6 +298,7 @@ files:
311
298
  - spec/ssl_integration_spec.rb
312
299
  - spec/token_spec.rb
313
300
  - spec/user_spec.rb
301
+ - version.txt
314
302
  homepage: https://github.com/cloudfoundry/cf-uaac
315
303
  licenses:
316
304
  - Apache-2.0
@@ -330,20 +318,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
330
318
  - !ruby/object:Gem::Version
331
319
  version: '0'
332
320
  requirements: []
333
- rubyforge_project: cf-uaac
334
- rubygems_version: 2.6.11
321
+ rubygems_version: 3.1.6
335
322
  signing_key:
336
323
  specification_version: 4
337
324
  summary: Command line interface for CloudFoundry UAA
338
- test_files:
339
- - spec/client_reg_spec.rb
340
- - spec/common_spec.rb
341
- - spec/curl_spec.rb
342
- - spec/group_spec.rb
343
- - spec/http_spec.rb
344
- - spec/info_spec.rb
345
- - spec/setup_helper.rb
346
- - spec/spec_helper.rb
347
- - spec/ssl_integration_spec.rb
348
- - spec/token_spec.rb
349
- - spec/user_spec.rb
325
+ test_files: []