cf-uaa-lib 3.14.4 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/uaa/info.rb +0 -8
- data/lib/uaa/token_issuer.rb +9 -2
- data/lib/uaa/version.rb +1 -1
- data/spec/token_issuer_spec.rb +10 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8a741ef102742885eff043d198628e3bc05f0bcc98c752a57ce5f6b3c18bf43
|
4
|
+
data.tar.gz: 6ffc61520e49b04d65bd0404f577727986e3f625e6ef095fc8a0d361c50be5ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75d8062f4bdc94bc7375a18124f72b3664a2d4074a63699c4e55f52ae085375ae587e7c113859b345bd7476878d744ceb66320cd42ccc9ef3e02f0315e591f78
|
7
|
+
data.tar.gz: 223a89a483dfe638062240e4326e8c8e485b62a1e07108ed87feb5fff67ce1f5a705923939f23d6135bd4eeb6f8638cd60ae7638cc62ff2e1376aafe94720051
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# CloudFoundry UAA Gem
|
2
|
-
|
2
|
+
![Build status](https://github.com/cloudfoundry/cf-uaa-lib/actions/workflows/ruby.yml/badge.svg?branch=master)
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/cf-uaa-lib.png)](http://badge.fury.io/rb/cf-uaa-lib)
|
4
4
|
|
5
5
|
Client gem for interacting with the [CloudFoundry UAA server](https://github.com/cloudfoundry/uaa)
|
data/lib/uaa/info.rb
CHANGED
@@ -54,14 +54,6 @@ class Info
|
|
54
54
|
json_get(target, "/userinfo?schema=openid", key_style, "authorization" => auth_header)
|
55
55
|
end
|
56
56
|
|
57
|
-
# Gets various monitoring and status variables from the server.
|
58
|
-
# Authenticates using +name+ and +pwd+ for basic authentication.
|
59
|
-
# @param (see Misc.server)
|
60
|
-
# @return [Hash]
|
61
|
-
def varz(name, pwd)
|
62
|
-
json_get(target, "/varz", key_style, "authorization" => Http.basic_auth(name, pwd))
|
63
|
-
end
|
64
|
-
|
65
57
|
# Gets basic information about the target server, including version number,
|
66
58
|
# commit ID, and links to API endpoints.
|
67
59
|
# @return [Hash]
|
data/lib/uaa/token_issuer.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
|
14
14
|
require 'securerandom'
|
15
15
|
require 'uaa/http'
|
16
|
+
require 'cgi'
|
16
17
|
|
17
18
|
module CF::UAA
|
18
19
|
|
@@ -72,8 +73,13 @@ class TokenIssuer
|
|
72
73
|
if scope = Util.arglist(params.delete(:scope))
|
73
74
|
params[:scope] = Util.strlist(scope)
|
74
75
|
end
|
75
|
-
headers = {'content-type' => FORM_UTF8, 'accept' => JSON_UTF8
|
76
|
-
|
76
|
+
headers = {'content-type' => FORM_UTF8, 'accept' => JSON_UTF8}
|
77
|
+
if @basic_auth
|
78
|
+
headers['authorization'] = Http.basic_auth(@client_id, @client_secret)
|
79
|
+
else
|
80
|
+
headers['X-CF-ENCODED-CREDENTIALS'] = 'true'
|
81
|
+
headers['authorization'] = Http.basic_auth(CGI.escape(@client_id), CGI.escape(@client_secret))
|
82
|
+
end
|
77
83
|
reply = json_parse_reply(@key_style, *request(@token_target, :post,
|
78
84
|
'/oauth/token', Util.encode_form(params), headers))
|
79
85
|
raise BadResponse unless reply[jkey :token_type] && reply[jkey :access_token]
|
@@ -109,6 +115,7 @@ class TokenIssuer
|
|
109
115
|
@target, @client_id, @client_secret = target, client_id, client_secret
|
110
116
|
@token_target = options[:token_target] || target
|
111
117
|
@key_style = options[:symbolize_keys] ? :sym : nil
|
118
|
+
@basic_auth = options[:basic_auth] == true ? true : false
|
112
119
|
initialize_http_options(options)
|
113
120
|
end
|
114
121
|
|
data/lib/uaa/version.rb
CHANGED
data/spec/token_issuer_spec.rb
CHANGED
@@ -23,13 +23,13 @@ describe TokenIssuer do
|
|
23
23
|
|
24
24
|
before do
|
25
25
|
#Util.default_logger(:trace)
|
26
|
-
@issuer = TokenIssuer.new('http://test.uaa.target', 'test_client', '
|
26
|
+
@issuer = TokenIssuer.new('http://test.uaa.target', 'test_client', 'test!secret', options)
|
27
27
|
end
|
28
28
|
|
29
29
|
subject { @issuer }
|
30
30
|
|
31
31
|
describe 'initialize' do
|
32
|
-
let(:options) { {http_proxy: 'http-proxy.com', https_proxy: 'https-proxy.com', skip_ssl_validation: true} }
|
32
|
+
let(:options) { {http_proxy: 'http-proxy.com', https_proxy: 'https-proxy.com', skip_ssl_validation: true, basic_auth: false} }
|
33
33
|
|
34
34
|
it 'sets skip_ssl_validation' do
|
35
35
|
subject.skip_ssl_validation == true
|
@@ -42,7 +42,8 @@ describe TokenIssuer do
|
|
42
42
|
subject.set_request_handler do |url, method, body, headers|
|
43
43
|
headers['content-type'].should =~ /application\/x-www-form-urlencoded/
|
44
44
|
headers['accept'].should =~ /application\/json/
|
45
|
-
|
45
|
+
headers['X-CF-ENCODED-CREDENTIALS'].should == 'true'
|
46
|
+
headers['authorization'].should == 'Basic dGVzdF9jbGllbnQ6dGVzdCUyMXNlY3JldA=='
|
46
47
|
url.should == 'http://test.uaa.target/oauth/token'
|
47
48
|
method.should == :post
|
48
49
|
reply = {access_token: 'test_access_token', token_type: 'BEARER',
|
@@ -89,7 +90,8 @@ describe TokenIssuer do
|
|
89
90
|
subject.set_request_handler do |url, method, body, headers|
|
90
91
|
headers['content-type'].should =~ /application\/x-www-form-urlencoded/
|
91
92
|
headers['accept'].should =~ /application\/json/
|
92
|
-
|
93
|
+
headers['X-CF-ENCODED-CREDENTIALS'].should == 'true'
|
94
|
+
headers['authorization'].should == 'Basic dGVzdF9jbGllbnQ6dGVzdCUyMXNlY3JldA=='
|
93
95
|
url.should == 'http://test.uaa.target/oauth/token'
|
94
96
|
method.should == :post
|
95
97
|
reply = {access_token: 'test_access_token', token_type: 'BEARER',
|
@@ -108,7 +110,8 @@ describe TokenIssuer do
|
|
108
110
|
subject.set_request_handler do |url, method, body, headers|
|
109
111
|
headers['content-type'].should =~ /application\/x-www-form-urlencoded/
|
110
112
|
headers['accept'].should =~ /application\/json/
|
111
|
-
|
113
|
+
headers['X-CF-ENCODED-CREDENTIALS'].should == 'true'
|
114
|
+
headers['authorization'].should == 'Basic dGVzdF9jbGllbnQ6dGVzdCUyMXNlY3JldA=='
|
112
115
|
url.should == 'http://test.uaa.target/oauth/token'
|
113
116
|
body.should =~ /(^|&)passcode=12345($|&)/
|
114
117
|
body.should =~ /(^|&)grant_type=password($|&)/
|
@@ -250,7 +253,8 @@ describe TokenIssuer do
|
|
250
253
|
subject.set_request_handler do |url, method, body, headers|
|
251
254
|
headers['content-type'].should =~ /application\/x-www-form-urlencoded/
|
252
255
|
headers['accept'].should =~ /application\/json/
|
253
|
-
|
256
|
+
headers['X-CF-ENCODED-CREDENTIALS'].should == 'true'
|
257
|
+
headers['authorization'].should == 'Basic dGVzdF9jbGllbnQ6dGVzdCUyMXNlY3JldA=='
|
254
258
|
url.should match 'http://test.uaa.target/oauth/token'
|
255
259
|
method.should == :post
|
256
260
|
reply = {access_token: 'test_access_token', token_type: 'BEARER',
|
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
|
+
version: 4.0.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: 2022-01-
|
15
|
+
date: 2022-01-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: multi_json
|