cf-uaa-lib 4.0.7 → 4.0.8

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
2
  SHA256:
3
- metadata.gz: b781e21fc1ba09d3b505c1364732c06796e300b3ebe6cd2aa47ae5db97273980
4
- data.tar.gz: a779db80778bf2cf71a3f6e6f3d4f25f06a78893ef41fc954d7ff16fc88c11cf
3
+ metadata.gz: c1d85a9e186e6f61fe473527aac3465589b12f415d30b22d05f99731c4d604bf
4
+ data.tar.gz: 71a5e80bebadaa224e51f39ef59ccdb3bf263bfc375f3d9624d5c888b79c1094
5
5
  SHA512:
6
- metadata.gz: 6db15f33f198143ae11a1cb34017c33b4aa0427342a037946e4c2b4a1e98825ee315ea3e715ddbec34a567620a262f1a24c5200f985f58d51dffcf3a1160e83e
7
- data.tar.gz: de7b59d47820e1541caad9f333f62cc5b264038766e1cb5c4e8f074c857dcf36888b0920df1c98bede83735d7db67470905df181e7da23056889075222c9f136
6
+ metadata.gz: 1d12f9f7255e3e7728bbcbccf89593d3e3e13edc7547b9b420a985442903d91c29f708d79593b536e02619332060a18c74198ff530dac264d1048d923412bf08
7
+ data.tar.gz: 35e4042dccf44ff0e1dd36fd1ef639759648d226e09fe175c7fbe477d75ac601b9fc74c2c8e6a3665a1cb9ea4288c532c48f98e53b5018714f33a13113643ae4
@@ -12,7 +12,7 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  strategy:
14
14
  matrix:
15
- ruby-version: ['2.5', '2.7', '3.1', '3.2', '3.3']
15
+ ruby-version: ['2.5', '2.7', '3.1', '3.2', '3.3', '3.4']
16
16
 
17
17
  steps:
18
18
  - uses: actions/checkout@v4
data/cf-uaa-lib.gemspec CHANGED
@@ -32,6 +32,8 @@ Gem::Specification.new do |s|
32
32
 
33
33
  # dependencies
34
34
  s.add_dependency 'json', '~>2.7'
35
+ s.add_dependency 'mutex_m'
36
+ s.add_dependency 'base64'
35
37
  s.add_dependency 'httpclient', '~> 2.8', '>= 2.8.2.4'
36
38
  s.add_dependency 'addressable', '~> 2.8', '>= 2.8.0'
37
39
 
data/lib/uaa/http.rb CHANGED
@@ -11,6 +11,7 @@
11
11
  # subcomponent's license, as noted in the LICENSE file.
12
12
  #++
13
13
 
14
+ require 'mutex_m'
14
15
  require 'base64'
15
16
  require 'uaa/util'
16
17
  require 'httpclient'
@@ -83,6 +83,9 @@ class TokenIssuer
83
83
  headers['X-CF-ENCODED-CREDENTIALS'] = 'true'
84
84
  headers['authorization'] = Http.basic_auth(CGI.escape(@client_id), CGI.escape(@client_secret))
85
85
  end
86
+ elsif @client_auth_method == 'client_secret_post' && @client_secret && @client_id
87
+ params[:client_id] = @client_id
88
+ params[:client_secret] = @client_secret
86
89
  elsif @client_id && params[:code_verifier]
87
90
  params[:client_id] = @client_id
88
91
  else
data/lib/uaa/version.rb CHANGED
@@ -14,6 +14,6 @@
14
14
  # Cloud Foundry namespace
15
15
  module CF
16
16
  module UAA
17
- VERSION = '4.0.7'
17
+ VERSION = '4.0.8'
18
18
  end
19
19
  end
@@ -310,6 +310,41 @@ describe TokenIssuer do
310
310
 
311
311
  end
312
312
 
313
+
314
+ context 'with basic_auth using auth code grant' do
315
+ let(:options) { {basic_auth: true} }
316
+
317
+ it 'basic_auth with authorization code' do
318
+ subject.set_request_handler do |url, method, body, headers|
319
+ headers['content-type'].should =~ /application\/x-www-form-urlencoded/
320
+ headers['accept'].should =~ /application\/json/
321
+ headers['X-CF-ENCODED-CREDENTIALS'].should_not
322
+ headers['authorization'].should == 'Basic dGVzdF9jbGllbnQ6dGVzdCFzZWNyZXQ='
323
+ params = Util.decode_form(body)
324
+ params['code_verifier'].should_not
325
+ params['grant_type'].should == 'authorization_code'
326
+ url.should match 'http://test.uaa.target/oauth/token'
327
+ method.should == :post
328
+ reply = {access_token: 'test_access_token', token_type: 'BEARER',
329
+ scope: 'openid', expires_in: 98765}
330
+ [200, Util.json(reply), {'content-type' => 'application/json'}]
331
+ end
332
+ cburi = 'http://call.back/uri_path'
333
+ params = Util.decode_form(cburi[1])
334
+ params['code_challenge'].should_not
335
+ params['code_challenge_method'].should_not
336
+ redir_uri = subject.authcode_uri(cburi)
337
+ state = /state=([^&]+)/.match(redir_uri)[1]
338
+ reply_query = "state=#{state}&code=kz8%2F5gQZ2pc%3D"
339
+ token = subject.authcode_grant(redir_uri, reply_query)
340
+ token.should be_an_instance_of TokenInfo
341
+ token.info['access_token'].should == 'test_access_token'
342
+ token.info['token_type'].should =~ /^bearer$/i
343
+ token.info['scope'].should == 'openid'
344
+ token.info['expires_in'].should == 98765
345
+ end
346
+ end
347
+
313
348
  context 'pkce with own code verifier' do
314
349
  let(:options) { {basic_auth: false, code_verifier: 'umoq1e_4XMYXvfHlaO9mSlSI17OKfxnwfR5ZD-oYreFxyn8yQZ-ZHPZfUZ4n3WjY_tkOB_MAisSy4ddqsa6aoTU5ZOcX4ps3de933PczYlC8pZpKL8EQWaDZOnpOyB2W'} }
315
350
 
@@ -324,6 +359,38 @@ describe TokenIssuer do
324
359
  code_verifier.should == options[:code_verifier]
325
360
  code_challenge.should == 'TAnM2AKGgiQKOC16cRpMdF_55qwmz3B333cq6T18z0s'
326
361
  end
362
+
363
+ let(:client_secret) { nil }
364
+ it 'public token request with pkce without client_secret' do
365
+ subject.set_request_handler do |url, method, body, headers|
366
+ headers['content-type'].should =~ /application\/x-www-form-urlencoded/
367
+ headers['accept'].should =~ /application\/json/
368
+ headers['X-CF-ENCODED-CREDENTIALS'].should_not
369
+ headers['authorization'].should_not
370
+ params = Util.decode_form(body)
371
+ params['code_verifier'].should_not
372
+ params['grant_type'].should == 'authorization_code'
373
+ params['client_secret'].should_not
374
+ url.should match 'http://test.uaa.target/oauth/token'
375
+ method.should == :post
376
+ reply = {access_token: 'test_access_token', token_type: 'BEARER',
377
+ scope: 'openid', expires_in: 98765}
378
+ [200, Util.json(reply), {'content-type' => 'application/json'}]
379
+ end
380
+ cburi = 'http://call.back/uri_path'
381
+ params = Util.decode_form(cburi[1])
382
+ params['code_challenge'].should_not
383
+ params['code_challenge_method'].should_not
384
+ redir_uri = subject.authcode_uri(cburi)
385
+ state = /state=([^&]+)/.match(redir_uri)[1]
386
+ reply_query = "state=#{state}&code=kz8%2F5gQZ2pc%3D"
387
+ token = subject.authcode_grant(redir_uri, reply_query)
388
+ token.should be_an_instance_of TokenInfo
389
+ token.info['access_token'].should == 'test_access_token'
390
+ token.info['token_type'].should =~ /^bearer$/i
391
+ token.info['scope'].should == 'openid'
392
+ token.info['expires_in'].should == 98765
393
+ end
327
394
  end
328
395
 
329
396
  context 'no pkce active as this is the default' do
@@ -338,6 +405,40 @@ describe TokenIssuer do
338
405
  end
339
406
  end
340
407
 
408
+ context 'with client_auth_method using client_secret_post' do
409
+ let(:options) { {client_auth_method: 'client_secret_post'} }
410
+ let(:client_secret) { 'body!secret' }
411
+
412
+ it 'use client_secret_post in authorization code and expect client_id and secret in body' do
413
+ subject.set_request_handler do |url, method, body, headers|
414
+ headers['content-type'].should =~ /application\/x-www-form-urlencoded/
415
+ headers['accept'].should =~ /application\/json/
416
+ headers['X-CF-ENCODED-CREDENTIALS'].should_not
417
+ headers['authorization'].should_not
418
+ params = Util.decode_form(body)
419
+ params['code_verifier'].should_not
420
+ params['grant_type'].should == 'authorization_code'
421
+ params['client_id'].should == 'test_client'
422
+ params['client_secret'].should == 'body!secret'
423
+ url.should match 'http://test.uaa.target/oauth/token'
424
+ method.should == :post
425
+ reply = {access_token: 'test_access_token', token_type: 'BEARER',
426
+ scope: 'openid', expires_in: 98765}
427
+ [200, Util.json(reply), {'content-type' => 'application/json'}]
428
+ end
429
+ cburi = 'http://call.back/uri_path'
430
+ redir_uri = subject.authcode_uri(cburi)
431
+ state = /state=([^&]+)/.match(redir_uri)[1]
432
+ reply_query = "state=#{state}&code=kz8%2F5gQZ2pc%3D"
433
+ token = subject.authcode_grant(redir_uri, reply_query)
434
+ token.should be_an_instance_of TokenInfo
435
+ token.info['access_token'].should == 'test_access_token'
436
+ token.info['token_type'].should =~ /^bearer$/i
437
+ token.info['scope'].should == 'openid'
438
+ token.info['expires_in'].should == 98765
439
+ end
440
+ end
441
+
341
442
  end
342
443
 
343
444
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cf-uaa-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.7
4
+ version: 4.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Syer
@@ -9,10 +9,9 @@ authors:
9
9
  - Joel D'sa
10
10
  - Vidya Valmikinathan
11
11
  - Luke Taylor
12
- autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2024-11-19 00:00:00.000000000 Z
14
+ date: 2025-01-21 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
17
  name: json
@@ -28,6 +27,34 @@ dependencies:
28
27
  - - "~>"
29
28
  - !ruby/object:Gem::Version
30
29
  version: '2.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: mutex_m
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ - !ruby/object:Gem::Dependency
45
+ name: base64
46
+ requirement: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
31
58
  - !ruby/object:Gem::Dependency
32
59
  name: httpclient
33
60
  requirement: !ruby/object:Gem::Requirement
@@ -232,7 +259,6 @@ homepage: https://github.com/cloudfoundry/cf-uaa-lib
232
259
  licenses:
233
260
  - Apache-2.0
234
261
  metadata: {}
235
- post_install_message:
236
262
  rdoc_options: []
237
263
  require_paths:
238
264
  - lib
@@ -247,8 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
273
  - !ruby/object:Gem::Version
248
274
  version: '0'
249
275
  requirements: []
250
- rubygems_version: 3.5.22
251
- signing_key:
276
+ rubygems_version: 3.6.2
252
277
  specification_version: 4
253
278
  summary: Client library for CloudFoundry UAA
254
279
  test_files: []