cf-uaac 3.9.0 → 3.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/uaa/cli/config.rb +4 -1
- data/lib/uaa/cli/token.rb +3 -1
- data/lib/uaa/cli/version.rb +1 -1
- data/lib/uaa/stub/uaa.rb +39 -39
- data/spec/token_spec.rb +66 -43
- metadata +14 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfd5454d263e6da7b3bfd4a4af5aadc6025a7960
|
|
4
|
+
data.tar.gz: f6874a63ac34a6e68fd39d31a0deeb69fbaa6b91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0ebc2c42d29ccff07ae37d8905b26421954e404b5462ce1faa802fe66b6f4f7cc26e0f0d5c388b139983315ef5dc2114509b46750d3a06f6ae248278c3a89e4
|
|
7
|
+
data.tar.gz: 5b077bab9d8f4f001e15b25ac3e030d7154eb41b3daf7470574c90cc9ea10961950ec4bf0c89727149ddb38a971b4165d0bda97fe0d71edf23e08d92379e31b1
|
data/lib/uaa/cli/config.rb
CHANGED
|
@@ -97,7 +97,10 @@ class Config
|
|
|
97
97
|
|
|
98
98
|
def self.delete(tgt = nil, ctx = nil)
|
|
99
99
|
if tgt && ctx
|
|
100
|
-
@config[tgt][:contexts].
|
|
100
|
+
unless @config[tgt][:contexts].nil?
|
|
101
|
+
ctx = ctx.downcase.to_sym
|
|
102
|
+
@config[tgt][:contexts].delete(ctx)
|
|
103
|
+
end
|
|
101
104
|
@context = nil if tgt == @target && ctx == @context
|
|
102
105
|
elsif tgt
|
|
103
106
|
@config.delete(tgt)
|
data/lib/uaa/cli/token.rb
CHANGED
|
@@ -73,7 +73,9 @@ class TokenCli < CommonCli
|
|
|
73
73
|
def set_context(token_info)
|
|
74
74
|
return gripe "attempt to get token failed\n" unless token_info && token_info["access_token"]
|
|
75
75
|
contents = TokenCoder.decode(token_info["access_token"], verify: false)
|
|
76
|
-
|
|
76
|
+
new_context = contents["user_name"] || contents["client_id"] || "bad_token"
|
|
77
|
+
Config.delete(Config.target, new_context)
|
|
78
|
+
Config.context = new_context
|
|
77
79
|
did_save = true
|
|
78
80
|
(did_save &= Config.add_opts(user_id: contents["user_id"])) if contents["user_id"]
|
|
79
81
|
(did_save &= Config.add_opts(client_id: contents["client_id"])) if contents["client_id"]
|
data/lib/uaa/cli/version.rb
CHANGED
data/lib/uaa/stub/uaa.rb
CHANGED
|
@@ -298,45 +298,45 @@ class StubUAAConn < Stub::Base
|
|
|
298
298
|
return reply.json(400, error: 'unauthorized_client')
|
|
299
299
|
end
|
|
300
300
|
case params.delete('grant_type')
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
301
|
+
when 'authorization_code'
|
|
302
|
+
# TODO: need authcode store with requested scope, redir_uri must match
|
|
303
|
+
return if bad_params?(params, ['code', 'redirect_uri'], [])
|
|
304
|
+
user_id, scope = redeem_auth_code(client[:id], params['redirect_uri'], params['code'])
|
|
305
|
+
return reply.json(400, error: 'invalid_grant') unless user_id && scope
|
|
306
|
+
user = server.scim.get(user, :user, :id, :emails, :username)
|
|
307
|
+
reply.json(token_reply_info(client, scope, user, nil, true))
|
|
308
|
+
when 'password'
|
|
309
|
+
notPassword = bad_params?(params, ['username', 'password'], ['scope'])
|
|
310
|
+
notPasscode = bad_params?(params, ['passcode'], ['scope'])
|
|
311
|
+
return if notPasscode && notPassword
|
|
312
|
+
unless notPassword
|
|
313
|
+
username = params['username']
|
|
314
|
+
password = params['password']
|
|
315
|
+
end
|
|
316
|
+
unless notPasscode
|
|
317
|
+
username, password = Base64::urlsafe_decode64(params['passcode']).split
|
|
318
|
+
end
|
|
319
|
+
user = find_user(username, password)
|
|
320
|
+
return reply.json(400, error: 'invalid_grant') unless user
|
|
321
|
+
scope = calc_scope(client, user, params['scope'])
|
|
322
|
+
return reply.json(400, error: 'invalid_scope') unless scope
|
|
323
|
+
reply.json(200, token_reply_info(client, scope, user, nil, true))
|
|
324
|
+
when 'client_credentials'
|
|
325
|
+
return if bad_params?(params, [], ['scope'])
|
|
326
|
+
scope = calc_scope(client, nil, params['scope'])
|
|
327
|
+
return reply.json(400, error: 'invalid_scope') unless scope
|
|
328
|
+
reply.json(token_reply_info(client, scope))
|
|
329
|
+
when 'refresh_token'
|
|
330
|
+
return if bad_params?(params, ['refresh_token'], ['scope'])
|
|
331
|
+
return reply.json(400, error: 'invalid_grant') unless params['refresh_token'] == 'universal_refresh_token'
|
|
332
|
+
# TODO: max scope should come from refresh token, or user from refresh token
|
|
333
|
+
# this should use calc_scope when we know the user
|
|
334
|
+
scope = ids_to_names(client[:scope])
|
|
335
|
+
scope = Util.strlist(Util.arglist(params['scope'], scope) & scope)
|
|
336
|
+
return reply.json(400, error: 'invalid_scope') if scope.empty?
|
|
337
|
+
reply.json(token_reply_info(client, scope))
|
|
338
|
+
else
|
|
339
|
+
reply.json(400, error: 'unsupported_grant_type')
|
|
340
340
|
end
|
|
341
341
|
inject_error
|
|
342
342
|
end
|
data/spec/token_spec.rb
CHANGED
|
@@ -22,16 +22,16 @@ describe TokenCli do
|
|
|
22
22
|
|
|
23
23
|
before :all do
|
|
24
24
|
#Util.default_logger(:trace)
|
|
25
|
-
Cli.configure(
|
|
26
|
-
setup_target(authorities:
|
|
25
|
+
Cli.configure('', nil, StringIO.new, true)
|
|
26
|
+
setup_target(authorities: 'clients.read,scim.read,scim.write,uaa.resource')
|
|
27
27
|
Cli.run("token client get #{@test_client} -s #{@test_secret}").should be
|
|
28
|
-
Config.yaml.should include(
|
|
28
|
+
Config.yaml.should include('access_token')
|
|
29
29
|
@test_pwd_unescaped = "@~`!$@%#%^$^&*)(|}{[]\":';?><,./"
|
|
30
30
|
@test_pwd = Shellwords.escape(@test_pwd_unescaped)
|
|
31
31
|
@test_user = "test_user_#{Time.now.to_i}"
|
|
32
32
|
Cli.run("user add #{@test_user} -p #{@test_pwd} " +
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
'--emails sam@example.com,joNES@sample.com --given_name SamueL ' +
|
|
34
|
+
'--phones 801-555-1212 --family_name jonES').should be
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
after :all do
|
|
@@ -41,100 +41,123 @@ describe TokenCli do
|
|
|
41
41
|
cleanup_target
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
it
|
|
44
|
+
it 'logs in with implicit grant & posted credentials as a user' do
|
|
45
45
|
Cli.run("token get #{@test_user} #{@test_pwd}").should be
|
|
46
|
-
Cli.output.string.should include(
|
|
47
|
-
Cli.run(
|
|
46
|
+
Cli.output.string.should include('Successfully fetched token')
|
|
47
|
+
Cli.run('context')
|
|
48
48
|
Cli.output.string.should match /scope:.+password\.write openid.*$/
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
it
|
|
52
|
-
Cli.run(
|
|
51
|
+
it 'can request a specific scope' do
|
|
52
|
+
Cli.run('token delete')
|
|
53
53
|
Cli.output.truncate 0
|
|
54
54
|
Cli.run("token get --scope password.write #{@test_user} #{@test_pwd}").should be
|
|
55
|
-
Cli.output.string.should include(
|
|
56
|
-
Cli.run(
|
|
55
|
+
Cli.output.string.should include('Successfully fetched token')
|
|
56
|
+
Cli.run('context')
|
|
57
57
|
Cli.output.string.should match /scope: password\.write$/
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
it
|
|
61
|
-
Cli.run(
|
|
62
|
-
[
|
|
60
|
+
it 'decodes the token' do
|
|
61
|
+
Cli.run('token decode').should be
|
|
62
|
+
['user_name', 'exp', 'aud', 'scope', 'client_id', 'email', 'user_id'].each do |a|
|
|
63
63
|
Cli.output.string.should include(a)
|
|
64
64
|
end
|
|
65
|
-
Cli.output.string.should include(
|
|
65
|
+
Cli.output.string.should include('email: sam@example.com')
|
|
66
66
|
Cli.output.string.should include("user_name: #{@test_user}")
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
-
it
|
|
69
|
+
it 'gets authenticated user information' do
|
|
70
70
|
Cli.run("token get #{@test_user} #{@test_pwd}").should be
|
|
71
|
-
Cli.run(
|
|
71
|
+
Cli.run('me').should be
|
|
72
72
|
Cli.output.string.should include(@test_user)
|
|
73
73
|
end
|
|
74
74
|
|
|
75
|
-
it
|
|
75
|
+
it 'updates the user' do
|
|
76
76
|
Cli.run "context #{@test_client}"
|
|
77
77
|
Cli.run("user update #{@test_user} --emails #{@test_user}+1@example.com --phones 123-456-7890").should be
|
|
78
78
|
Cli.run("user get #{@test_user}").should be
|
|
79
|
-
Cli.output.string.should include(@test_user, "#{@test_user}+1@example.com",
|
|
79
|
+
Cli.output.string.should include(@test_user, "#{@test_user}+1@example.com", '123-456-7890')
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
it
|
|
82
|
+
it 'gets updated information in the token' do
|
|
83
83
|
Cli.run("token get #{@test_user} #{@test_pwd}").should be
|
|
84
|
-
Cli.output.string.should include(
|
|
85
|
-
Cli.run(
|
|
84
|
+
Cli.output.string.should include('Successfully fetched token')
|
|
85
|
+
Cli.run('token decode').should be
|
|
86
86
|
Cli.output.string.should include("email: #{@test_user}+1@example.com")
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
it
|
|
89
|
+
it 'gets ids for a username' do
|
|
90
90
|
Cli.run("user ids #{@test_user.downcase}").should be
|
|
91
|
-
Cli.output.string.should include(@test_user,
|
|
91
|
+
Cli.output.string.should include(@test_user, 'id')
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
it
|
|
95
|
-
Cli.run(
|
|
96
|
-
Cli.output.string.should include
|
|
94
|
+
it 'has multiple distinct authentication contexts' do
|
|
95
|
+
Cli.run('contexts').should be
|
|
96
|
+
Cli.output.string.should include '[admin]', "[#{@test_client}]", "[#{@test_user.downcase}]"
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
it
|
|
99
|
+
it 'removes the user context' do
|
|
100
100
|
Cli.run("token delete #{@test_user}").should be
|
|
101
|
-
Cli.run
|
|
102
|
-
Cli.output.string.should include
|
|
101
|
+
Cli.run 'contexts'
|
|
102
|
+
Cli.output.string.should include '[admin]', "[#{@test_client}]"
|
|
103
103
|
Cli.output.string.should_not include "#{@test_user}"
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
it
|
|
106
|
+
it 'logs in with owner password grant' do
|
|
107
107
|
Cli.run("token owner get #{@test_client} -s #{@test_secret} #{@test_user} -p #{@test_pwd}" ).should be
|
|
108
|
-
Cli.output.string.should include
|
|
108
|
+
Cli.output.string.should include 'Successfully fetched token'
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
-
it
|
|
111
|
+
it 'logs in with sso passcode grant' do
|
|
112
112
|
fakePasscode = Base64::urlsafe_encode64("#{@test_user} #{@test_pwd_unescaped}")
|
|
113
113
|
cli_run = Cli.run("token sso get #{@test_client} -s #{@test_secret} --passcode #{fakePasscode}")
|
|
114
114
|
cli_run.should be
|
|
115
|
-
Cli.output.string.should include
|
|
115
|
+
Cli.output.string.should include 'Successfully fetched token'
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
it
|
|
119
|
-
Cli.run(
|
|
120
|
-
[
|
|
118
|
+
it 'decodes the owner token' do
|
|
119
|
+
Cli.run('token decode').should be
|
|
120
|
+
['user_name', 'exp', 'aud', 'scope', 'client_id', 'email', 'user_id', 'openid', 'password.write'].each do |a|
|
|
121
121
|
Cli.output.string.should include a
|
|
122
122
|
end
|
|
123
123
|
end
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
describe 'when client_id is same as user_name' do
|
|
126
|
+
before :each do
|
|
127
|
+
Cli.run("token client get #{@admin_client} -s #{@admin_secret}").should be
|
|
128
|
+
Cli.run("client add #{@test_user} -s #{@test_secret} " +
|
|
129
|
+
"--authorities uaa.resource " +
|
|
130
|
+
"--scope openid " +
|
|
131
|
+
"--authorized_grant_types client_credentials " +
|
|
132
|
+
"--autoapprove uaa.resource " +
|
|
133
|
+
"--signup_redirect_url home")
|
|
134
|
+
Cli.output.string.should include 'created_by'
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'does not contain refresh token for client-credentials token' do
|
|
138
|
+
Cli.run("token owner get #{@test_client} -s #{@test_secret} #{@test_user} -p #{@test_pwd}" ).should be
|
|
139
|
+
Cli.run('context')
|
|
140
|
+
Cli.output.string.should include 'refresh_token'
|
|
141
|
+
|
|
142
|
+
Cli.run("token client get #{@test_user} -s #{@test_secret}" ).should be
|
|
143
|
+
Cli.run('context')
|
|
144
|
+
Cli.output.string.should_not include 'refresh_token'
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
it 'gets the server signing key' do
|
|
126
149
|
Cli.run("signing key -c #{@test_client} -s #{@test_secret}").should be
|
|
127
150
|
Cli.output.string.should include 'alg:', 'value:'
|
|
128
151
|
end
|
|
129
152
|
|
|
130
|
-
it
|
|
131
|
-
pending
|
|
153
|
+
it 'uses the token endpoint given by the login server' do
|
|
154
|
+
pending 'only saml login server returns token endpoint' if ENV['UAA_CLIENT_TARGET']
|
|
132
155
|
@stub_uaa.info[:token_endpoint] = te = "#{@stub_uaa.url}/alternate"
|
|
133
156
|
Cli.run("target #{@target} --config")
|
|
134
157
|
Cli.run("token client get #{@test_client} -s #{@test_secret}").should be
|
|
135
|
-
Config.yaml.should include(
|
|
158
|
+
Config.yaml.should include('access_token', 'token_endpoint', te)
|
|
136
159
|
@stub_uaa.info[:token_endpoint].should be_nil
|
|
137
|
-
Cli.configure(
|
|
160
|
+
Cli.configure('', nil, StringIO.new) # clean up
|
|
138
161
|
Cli.run("target #{@target}").should be
|
|
139
162
|
Cli.run("token client get #{@admin_client} -s #{@admin_secret}").should be
|
|
140
163
|
end
|
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.
|
|
4
|
+
version: 3.10.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-03-
|
|
15
|
+
date: 2017-03-24 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: cf-uaa-lib
|
|
@@ -347,4 +347,15 @@ rubygems_version: 2.5.1
|
|
|
347
347
|
signing_key:
|
|
348
348
|
specification_version: 4
|
|
349
349
|
summary: Command line interface for CloudFoundry UAA
|
|
350
|
-
test_files:
|
|
350
|
+
test_files:
|
|
351
|
+
- spec/client_reg_spec.rb
|
|
352
|
+
- spec/common_spec.rb
|
|
353
|
+
- spec/curl_spec.rb
|
|
354
|
+
- spec/group_spec.rb
|
|
355
|
+
- spec/http_spec.rb
|
|
356
|
+
- spec/info_spec.rb
|
|
357
|
+
- spec/setup_helper.rb
|
|
358
|
+
- spec/spec_helper.rb
|
|
359
|
+
- spec/ssl_integration_spec.rb
|
|
360
|
+
- spec/token_spec.rb
|
|
361
|
+
- spec/user_spec.rb
|