cf-uaa-lib 1.3.10 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -0
- data/lib/uaa.rb +1 -1
- data/lib/uaa/http.rb +24 -9
- data/lib/uaa/{misc.rb → info.rb} +33 -24
- data/lib/uaa/proxy_options.rb +17 -0
- data/lib/uaa/scim.rb +2 -0
- data/lib/uaa/token_issuer.rb +2 -0
- data/lib/uaa/version.rb +1 -1
- data/spec/http_spec.rb +21 -4
- data/spec/info_spec.rb +118 -0
- data/spec/scim_spec.rb +12 -4
- data/spec/spec_helper.rb +1 -4
- data/spec/token_issuer_spec.rb +12 -3
- metadata +92 -130
- data/spec/misc_spec.rb +0 -94
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# CloudFoundry UAA Gem
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/cf-uaa-lib.png)](http://badge.fury.io/rb/cf-uaa-lib)
|
4
|
+
|
3
5
|
Client gem for interacting with the [CloudFoundry UAA server](https://github.com/cloudfoundry/uaa)
|
4
6
|
|
5
7
|
For documentation see: https://rubygems.org/gems/cf-uaa-lib
|
data/lib/uaa.rb
CHANGED
data/lib/uaa/http.rb
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
require 'base64'
|
15
15
|
require 'net/http'
|
16
16
|
require 'uaa/util'
|
17
|
+
require 'uaa/proxy_options'
|
17
18
|
|
18
19
|
module CF::UAA
|
19
20
|
|
@@ -42,6 +43,13 @@ class InvalidToken < TargetError; end
|
|
42
43
|
|
43
44
|
# Utility accessors and methods for objects that want to access JSON web APIs.
|
44
45
|
module Http
|
46
|
+
include ProxyOptions
|
47
|
+
|
48
|
+
def self.included(base)
|
49
|
+
base.class_eval do
|
50
|
+
attr_accessor :http_proxy, :https_proxy
|
51
|
+
end
|
52
|
+
end
|
45
53
|
|
46
54
|
# Sets the current logger instance to recieve error messages.
|
47
55
|
# @param [Logger] logr
|
@@ -144,15 +152,7 @@ module Http
|
|
144
152
|
uri = URI.parse(url)
|
145
153
|
req = reqtype.new(uri.request_uri)
|
146
154
|
headers.each { |k, v| req[k] = v }
|
147
|
-
|
148
|
-
@http_cache ||= {}
|
149
|
-
unless http = @http_cache[http_key]
|
150
|
-
@http_cache[http_key] = http = Net::HTTP.new(uri.host, uri.port)
|
151
|
-
if uri.is_a?(URI::HTTPS)
|
152
|
-
http.use_ssl = true
|
153
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
154
|
-
end
|
155
|
-
end
|
155
|
+
http = http_request(uri)
|
156
156
|
reply, outhdrs = http.request(req, body), {}
|
157
157
|
reply.each_header { |k, v| outhdrs[k] = v }
|
158
158
|
[reply.code.to_i, reply.body, outhdrs]
|
@@ -163,6 +163,21 @@ module Http
|
|
163
163
|
raise HTTPException, "HTTP exception: #{e.class}: #{e}"
|
164
164
|
end
|
165
165
|
|
166
|
+
def http_request(uri)
|
167
|
+
cache_key = URI.join(uri.to_s, "/")
|
168
|
+
@http_cache ||= {}
|
169
|
+
return @http_cache[cache_key] if @http_cache[cache_key]
|
170
|
+
|
171
|
+
http = Net::HTTP.new(uri.host, uri.port, *proxy_options_for(uri))
|
172
|
+
|
173
|
+
if uri.is_a?(URI::HTTPS)
|
174
|
+
http.use_ssl = true
|
175
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
176
|
+
end
|
177
|
+
|
178
|
+
@http_cache[cache_key] = http
|
179
|
+
end
|
180
|
+
|
166
181
|
end
|
167
182
|
|
168
183
|
end
|
data/lib/uaa/{misc.rb → info.rb}
RENAMED
@@ -17,15 +17,30 @@ module CF::UAA
|
|
17
17
|
|
18
18
|
# Provides interfaces to various UAA endpoints that are not in the context
|
19
19
|
# of an overall class of operations like SCIM resources or OAuth2 tokens.
|
20
|
-
class
|
20
|
+
class Info
|
21
|
+
include Http
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
attr_accessor :target
|
24
|
+
attr_reader :key_style
|
25
|
+
|
26
|
+
# @param [String] target The base URL of the server. For example the target could
|
27
|
+
# be {https://login.cloudfoundry.com}, {https://uaa.cloudfoundry.com}, or
|
28
|
+
# {http://localhost:8080/uaa}.
|
29
|
+
# @param [Hash] options can be
|
30
|
+
# * +:symbolize_keys+, If set to true, response hashes will have symbols for their keys, otherwise
|
31
|
+
# string keys are returned.
|
32
|
+
def initialize(target, options = {})
|
33
|
+
self.target = target
|
34
|
+
self.symbolize_keys = options[:symbolize_keys]
|
35
|
+
self.http_proxy = options[:http_proxy]
|
36
|
+
self.https_proxy = options[:https_proxy]
|
24
37
|
end
|
25
38
|
|
26
39
|
# sets whether the keys in returned hashes should be symbols.
|
27
40
|
# @return [Boolean] the new state
|
28
|
-
def
|
41
|
+
def symbolize_keys=(bool)
|
42
|
+
@key_style = bool ? :sym : nil
|
43
|
+
end
|
29
44
|
|
30
45
|
# Gets information about the user authenticated by the token in the
|
31
46
|
# +auth_header+. It GETs from the +target+'s +/userinfo+ endpoint and
|
@@ -36,38 +51,32 @@ class Misc
|
|
36
51
|
# @param (see Misc.server)
|
37
52
|
# @param [String] auth_header see {TokenInfo#auth_header}
|
38
53
|
# @return [Hash]
|
39
|
-
def
|
40
|
-
json_get(target, "/userinfo?schema=openid",
|
54
|
+
def whoami(auth_header)
|
55
|
+
json_get(target, "/userinfo?schema=openid", key_style, "authorization" => auth_header)
|
41
56
|
end
|
42
57
|
|
43
58
|
# Gets various monitoring and status variables from the server.
|
44
59
|
# Authenticates using +name+ and +pwd+ for basic authentication.
|
45
60
|
# @param (see Misc.server)
|
46
61
|
# @return [Hash]
|
47
|
-
def
|
48
|
-
json_get(target, "/varz",
|
62
|
+
def varz(name, pwd)
|
63
|
+
json_get(target, "/varz", key_style, "authorization" => Http.basic_auth(name, pwd))
|
49
64
|
end
|
50
65
|
|
51
66
|
# Gets basic information about the target server, including version number,
|
52
67
|
# commit ID, and links to API endpoints.
|
53
|
-
# @param [String] target The base URL of the server. For example the target could
|
54
|
-
# be {https://login.cloudfoundry.com}, {https://uaa.cloudfoundry.com}, or
|
55
|
-
# {http://localhost:8080/uaa}.
|
56
68
|
# @return [Hash]
|
57
|
-
def
|
58
|
-
reply = json_get(target, '/login',
|
69
|
+
def server
|
70
|
+
reply = json_get(target, '/login', key_style)
|
59
71
|
return reply if reply && (reply[:prompts] || reply['prompts'])
|
60
72
|
raise BadResponse, "Invalid response from target #{target}"
|
61
73
|
end
|
62
74
|
|
63
75
|
# Gets a base url for the associated UAA from the target server by inspecting the
|
64
76
|
# links returned from its info endpoint.
|
65
|
-
# @param [String] target The base URL of the server. For example the target could
|
66
|
-
# be {https://login.cloudfoundry.com}, {https://uaa.cloudfoundry.com}, or
|
67
|
-
# {http://localhost:8080/uaa}.
|
68
77
|
# @return [String] url of UAA (or the target itself if it didn't provide a response)
|
69
|
-
def
|
70
|
-
info = server
|
78
|
+
def discover_uaa
|
79
|
+
info = server
|
71
80
|
links = info['links'] || info[:links]
|
72
81
|
uaa = links && (links['uaa'] || links[:uaa])
|
73
82
|
|
@@ -81,10 +90,10 @@ class Misc
|
|
81
90
|
# public key and +client_id+ must be nil.
|
82
91
|
# @param (see Misc.server)
|
83
92
|
# @return [Hash]
|
84
|
-
def
|
93
|
+
def validation_key(client_id = nil, client_secret = nil)
|
85
94
|
hdrs = client_id && client_secret ?
|
86
95
|
{ "authorization" => Http.basic_auth(client_id, client_secret)} : {}
|
87
|
-
json_get(target, "/token_key",
|
96
|
+
json_get(target, "/token_key", key_style, hdrs)
|
88
97
|
end
|
89
98
|
|
90
99
|
# Sends +token+ to the server to validate and decode. Authenticates with
|
@@ -96,9 +105,9 @@ class Misc
|
|
96
105
|
# also {TokenInfo}.
|
97
106
|
# @param [String] token_type as retrieved by {TokenIssuer}. See {TokenInfo}.
|
98
107
|
# @return [Hash] contents of the token
|
99
|
-
def
|
108
|
+
def decode_token(client_id, client_secret, token, token_type = "bearer", audience_ids = nil)
|
100
109
|
reply = json_get(target, "/check_token?token_type=#{token_type}&token=#{token}",
|
101
|
-
|
110
|
+
key_style, "authorization" => Http.basic_auth(client_id, client_secret))
|
102
111
|
auds = Util.arglist(reply[:aud] || reply['aud'])
|
103
112
|
if audience_ids && (!auds || (auds & audience_ids).empty?)
|
104
113
|
raise AuthError, "invalid audience: #{auds.join(' ')}"
|
@@ -110,8 +119,8 @@ class Misc
|
|
110
119
|
# an indication of what strength is required.
|
111
120
|
# @param (see Misc.server)
|
112
121
|
# @return [Hash]
|
113
|
-
def
|
114
|
-
json_parse_reply(
|
122
|
+
def password_strength(password)
|
123
|
+
json_parse_reply(key_style, *request(target, :post, '/password/score',
|
115
124
|
Util.encode_form(:password => password), "content-type" => Http::FORM_UTF8,
|
116
125
|
"accept" => Http::JSON_UTF8))
|
117
126
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module CF::UAA
|
2
|
+
module ProxyOptions
|
3
|
+
def proxy_options_for(uri)
|
4
|
+
ssl = uri.is_a?(URI::HTTPS)
|
5
|
+
proxy_to_use = (ssl ? https_proxy : http_proxy)
|
6
|
+
|
7
|
+
if proxy_to_use
|
8
|
+
proxy_to_use = "proto://#{proxy_to_use}" unless proxy_to_use =~ /:\/\//
|
9
|
+
proxy_uri = URI.parse(proxy_to_use)
|
10
|
+
proxy_user, proxy_password = proxy_uri.userinfo.split(/:/) if proxy_uri.userinfo
|
11
|
+
[proxy_uri.host, proxy_uri.port, proxy_user, proxy_password]
|
12
|
+
else
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/uaa/scim.rb
CHANGED
@@ -99,6 +99,8 @@ class Scim
|
|
99
99
|
def initialize(target, auth_header, options = {})
|
100
100
|
@target, @auth_header = target, auth_header
|
101
101
|
@key_style = options[:symbolize_keys] ? :downsym : :down
|
102
|
+
self.http_proxy = options[:http_proxy]
|
103
|
+
self.https_proxy = options[:https_proxy]
|
102
104
|
end
|
103
105
|
|
104
106
|
# Convenience method to get the naming attribute, e.g. userName for user,
|
data/lib/uaa/token_issuer.rb
CHANGED
@@ -109,6 +109,8 @@ class TokenIssuer
|
|
109
109
|
@target, @client_id, @client_secret = target, client_id, client_secret
|
110
110
|
@token_target = options[:token_target] || target
|
111
111
|
@key_style = options[:symbolize_keys] ? :sym : nil
|
112
|
+
self.http_proxy = options[:http_proxy]
|
113
|
+
self.https_proxy = options[:https_proxy]
|
112
114
|
end
|
113
115
|
|
114
116
|
# Allows an app to discover what credentials are required for
|
data/lib/uaa/version.rb
CHANGED
data/spec/http_spec.rb
CHANGED
@@ -19,19 +19,36 @@ module CF::UAA
|
|
19
19
|
|
20
20
|
describe Http do
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
class HttpTest
|
23
|
+
include Http
|
24
|
+
|
25
|
+
public :http_get
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:http_instance) { HttpTest.new }
|
24
29
|
|
25
30
|
it "sets a request handler" do
|
26
|
-
set_request_handler do |url, method, body, headers|
|
31
|
+
http_instance.set_request_handler do |url, method, body, headers|
|
27
32
|
[200, "body", {"content-type" => "text/plain"}]
|
28
33
|
end
|
29
|
-
status, body, resp_headers = http_get("http://example.com")
|
34
|
+
status, body, resp_headers = http_instance.http_get("http://example.com")
|
30
35
|
status.should == 200
|
31
36
|
body.should == "body"
|
32
37
|
resp_headers["content-type"].should == "text/plain"
|
33
38
|
end
|
34
39
|
|
40
|
+
it "utilizes proxy settings if given" do
|
41
|
+
reply_double = double('http reply', each_header: {}).as_null_object
|
42
|
+
http_double = double('http', request: reply_double, new: nil)
|
43
|
+
Net::HTTP.stub(:new).and_return(http_double)
|
44
|
+
http_instance.http_proxy = 'user:password@http-proxy.example.com:1234'
|
45
|
+
http_instance.https_proxy = 'user:password@https-proxy.example.com:1234'
|
46
|
+
|
47
|
+
http_instance.http_get("http://example.com")
|
48
|
+
|
49
|
+
expect(Net::HTTP).to have_received(:new).with(anything, anything, 'http-proxy.example.com', 1234, 'user', 'password')
|
50
|
+
end
|
51
|
+
|
35
52
|
end
|
36
53
|
|
37
54
|
end
|
data/spec/info_spec.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
#--
|
2
|
+
# Cloud Foundry 2012.02.03 Beta
|
3
|
+
# Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
|
4
|
+
#
|
5
|
+
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
6
|
+
# You may not use this product except in compliance with the License.
|
7
|
+
#
|
8
|
+
# This product includes a number of subcomponents with
|
9
|
+
# separate copyright notices and license terms. Your use of these
|
10
|
+
# subcomponents is subject to the terms and conditions of the
|
11
|
+
# subcomponent's license, as noted in the LICENSE file.
|
12
|
+
#++
|
13
|
+
|
14
|
+
require 'spec_helper'
|
15
|
+
require 'uaa/info'
|
16
|
+
|
17
|
+
module CF::UAA
|
18
|
+
|
19
|
+
describe Info do
|
20
|
+
let(:options) { {} }
|
21
|
+
let(:uaa_info) { Info.new(target, options) }
|
22
|
+
let(:target) { "https://login.cloudfoundry.com" }
|
23
|
+
let(:authorization) { nil }
|
24
|
+
|
25
|
+
before do
|
26
|
+
uaa_info.set_request_handler do |url, method, body, headers|
|
27
|
+
url.should == target_url
|
28
|
+
method.should == :get
|
29
|
+
headers["content-type"].should be_nil
|
30
|
+
headers["accept"].gsub(/\s/, '').should =~ /application\/json;charset=utf-8/i
|
31
|
+
headers["authorization"].should == authorization
|
32
|
+
[200, response_body, {"content-type" => "application/json"}]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "initialize" do
|
37
|
+
let(:options) { {:http_proxy => 'http-proxy.com', :https_proxy => 'https-proxy.com'} }
|
38
|
+
|
39
|
+
it "sets proxy information" do
|
40
|
+
uaa_info.http_proxy.should == 'http-proxy.com'
|
41
|
+
uaa_info.https_proxy.should == 'https-proxy.com'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "getting server info" do
|
46
|
+
let(:target_url) { "https://login.cloudfoundry.com/login" }
|
47
|
+
let(:response_body) { '{"commit_id":"12345","prompts":["one","two"]}' }
|
48
|
+
|
49
|
+
it "gets server info" do
|
50
|
+
result = uaa_info.server
|
51
|
+
result["prompts"].should_not be_nil
|
52
|
+
result["commit_id"].should_not be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with symbolize_keys keys true" do
|
56
|
+
let(:options) { {:symbolize_keys => true} }
|
57
|
+
|
58
|
+
it "gets server info" do
|
59
|
+
result = uaa_info.server
|
60
|
+
result[:prompts].should_not be_nil
|
61
|
+
result[:commit_id].should_not be_nil
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "getting UAA target" do
|
67
|
+
let(:target) { "https://login.cloudfoundry.com" }
|
68
|
+
let(:target_url) { "https://login.cloudfoundry.com/login" }
|
69
|
+
let(:response_body) { '{"links":{"uaa":"https://uaa.cloudfoundry.com"},"prompts":["one","two"]}' }
|
70
|
+
|
71
|
+
it "gets UAA target" do
|
72
|
+
result = uaa_info.discover_uaa
|
73
|
+
result.should == "https://uaa.cloudfoundry.com"
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when there is no 'links' key present" do
|
77
|
+
let(:target) { "https://uaa.cloudfoundry.com" }
|
78
|
+
let(:target_url) { "https://uaa.cloudfoundry.com/login" }
|
79
|
+
let(:response_body) { '{ "prompts" : ["one","two"]} ' }
|
80
|
+
|
81
|
+
it "returns the target url" do
|
82
|
+
result = uaa_info.discover_uaa
|
83
|
+
result.should == "https://uaa.cloudfoundry.com"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "with symbolize_keys keys true" do
|
88
|
+
let(:options) { {:symbolize_keys => true} }
|
89
|
+
|
90
|
+
it "gets UAA target" do
|
91
|
+
result = uaa_info.discover_uaa
|
92
|
+
result.should == "https://uaa.cloudfoundry.com"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "whoami" do
|
98
|
+
let(:target_url) { "https://login.cloudfoundry.com/userinfo?schema=openid" }
|
99
|
+
let(:response_body) { '{"user_id":"1111-1111-1111-1111","user_name":"user","given_name":"first","family_name":"last","name":"first last","email":"email@example.com"}' }
|
100
|
+
let(:authorization) { 'authentication_token' }
|
101
|
+
|
102
|
+
it "returns the user info" do
|
103
|
+
result = uaa_info.whoami(authorization)
|
104
|
+
result['email'].should == 'email@example.com'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "validation_key" do
|
109
|
+
let(:target_url) { "https://login.cloudfoundry.com/token_key" }
|
110
|
+
let(:response_body) { '{"alg":"SHA256withRSA","value":"-----BEGIN PUBLIC KEY-----\nabc123\n-----END PUBLIC KEY-----\n"}' }
|
111
|
+
|
112
|
+
it "returns the key data" do
|
113
|
+
result = uaa_info.validation_key(authorization)
|
114
|
+
result['alg'].should == 'SHA256withRSA'
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/spec/scim_spec.rb
CHANGED
@@ -17,13 +17,12 @@ require 'uaa/scim'
|
|
17
17
|
module CF::UAA
|
18
18
|
|
19
19
|
describe Scim do
|
20
|
+
let(:options) { {} }
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
before :all do
|
22
|
+
before do
|
24
23
|
#Util.default_logger(:trace)
|
25
24
|
@authheader, @target = "bEareR xyz", "https://test.target"
|
26
|
-
@scim = Scim.new(@target, @authheader)
|
25
|
+
@scim = Scim.new(@target, @authheader, options)
|
27
26
|
end
|
28
27
|
|
29
28
|
subject { @scim }
|
@@ -36,6 +35,15 @@ describe Scim do
|
|
36
35
|
headers["authorization"].should =~ /^(?i:bearer)\s+xyz$/
|
37
36
|
end
|
38
37
|
|
38
|
+
describe "initialize" do
|
39
|
+
let(:options) { {:http_proxy => 'http-proxy.com', :https_proxy => 'https-proxy.com'} }
|
40
|
+
|
41
|
+
it "sets proxy information" do
|
42
|
+
subject.http_proxy.should == 'http-proxy.com'
|
43
|
+
subject.https_proxy.should == 'https-proxy.com'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
39
47
|
it "adds an object" do
|
40
48
|
subject.set_request_handler do |url, method, body, headers|
|
41
49
|
url.should == "#{@target}/Users"
|
data/spec/spec_helper.rb
CHANGED
data/spec/token_issuer_spec.rb
CHANGED
@@ -19,15 +19,24 @@ module CF::UAA
|
|
19
19
|
|
20
20
|
describe TokenIssuer do
|
21
21
|
|
22
|
-
|
22
|
+
let(:options) { {} }
|
23
23
|
|
24
|
-
before
|
24
|
+
before do
|
25
25
|
#Util.default_logger(:trace)
|
26
|
-
@issuer = TokenIssuer.new("http://test.uaa.target", "test_client", "test_secret")
|
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
|
+
describe "initialize" do
|
32
|
+
let(:options) { {:http_proxy => 'http-proxy.com', :https_proxy => 'https-proxy.com'} }
|
33
|
+
|
34
|
+
it "sets proxy information" do
|
35
|
+
subject.http_proxy.should == 'http-proxy.com'
|
36
|
+
subject.https_proxy.should == 'https-proxy.com'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
context "with client credentials grant" do
|
32
41
|
|
33
42
|
it "gets a token with client credentials" do
|
metadata
CHANGED
@@ -1,15 +1,10 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: cf-uaa-lib
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 10
|
10
|
-
version: 1.3.10
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Dave Syer
|
14
9
|
- Dale Olds
|
15
10
|
- Joel D'sa
|
@@ -18,135 +13,111 @@ authors:
|
|
18
13
|
autorequire:
|
19
14
|
bindir: bin
|
20
15
|
cert_chain: []
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
- !ruby/object:Gem::Dependency
|
16
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
25
19
|
name: multi_json
|
26
|
-
|
27
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
requirement: &74137320 !ruby/object:Gem::Requirement
|
28
21
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
|
33
|
-
segments:
|
34
|
-
- 0
|
35
|
-
version: "0"
|
22
|
+
requirements:
|
23
|
+
- - ! '>='
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: '0'
|
36
26
|
type: :runtime
|
37
|
-
version_requirements: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: bundler
|
40
27
|
prerelease: false
|
41
|
-
|
28
|
+
version_requirements: *74137320
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundler
|
31
|
+
requirement: &74137000 !ruby/object:Gem::Requirement
|
42
32
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
47
|
-
segments:
|
48
|
-
- 0
|
49
|
-
version: "0"
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
50
37
|
type: :development
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: rake
|
54
38
|
prerelease: false
|
55
|
-
|
39
|
+
version_requirements: *74137000
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: rake
|
42
|
+
requirement: &74136670 !ruby/object:Gem::Requirement
|
56
43
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
version: "0"
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
64
48
|
type: :development
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: rspec
|
68
49
|
prerelease: false
|
69
|
-
|
50
|
+
version_requirements: *74136670
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rspec
|
53
|
+
requirement: &74136380 !ruby/object:Gem::Requirement
|
70
54
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
78
59
|
type: :development
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: simplecov
|
82
60
|
prerelease: false
|
83
|
-
|
61
|
+
version_requirements: *74136380
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: simplecov
|
64
|
+
requirement: &74135650 !ruby/object:Gem::Requirement
|
84
65
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
version: "0"
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
92
70
|
type: :development
|
93
|
-
version_requirements: *id005
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: simplecov-rcov
|
96
71
|
prerelease: false
|
97
|
-
|
72
|
+
version_requirements: *74135650
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: simplecov-rcov
|
75
|
+
requirement: &74135270 !ruby/object:Gem::Requirement
|
98
76
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
version: "0"
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
106
81
|
type: :development
|
107
|
-
version_requirements: *id006
|
108
|
-
- !ruby/object:Gem::Dependency
|
109
|
-
name: ci_reporter
|
110
82
|
prerelease: false
|
111
|
-
|
83
|
+
version_requirements: *74135270
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: ci_reporter
|
86
|
+
requirement: &74134990 !ruby/object:Gem::Requirement
|
112
87
|
none: false
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
|
117
|
-
segments:
|
118
|
-
- 0
|
119
|
-
version: "0"
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
120
92
|
type: :development
|
121
|
-
version_requirements: *id007
|
122
|
-
- !ruby/object:Gem::Dependency
|
123
|
-
name: json_pure
|
124
93
|
prerelease: false
|
125
|
-
|
94
|
+
version_requirements: *74134990
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: json_pure
|
97
|
+
requirement: &74134660 !ruby/object:Gem::Requirement
|
126
98
|
none: false
|
127
|
-
requirements:
|
128
|
-
- -
|
129
|
-
- !ruby/object:Gem::Version
|
130
|
-
|
131
|
-
segments:
|
132
|
-
- 0
|
133
|
-
version: "0"
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
134
103
|
type: :development
|
135
|
-
|
136
|
-
|
137
|
-
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: *74134660
|
106
|
+
description: Client library for interacting with the CloudFoundry User Account and
|
107
|
+
Authorization (UAA) server. The UAA is an OAuth2 Authorization Server so it can
|
108
|
+
be used by webapps and command line apps to obtain access tokens to act on behalf
|
109
|
+
of users. The tokens can then be used to access protected resources in a Resource
|
110
|
+
Server. This library is for use by UAA client applications or resource servers.
|
111
|
+
email:
|
138
112
|
- dsyer@vmware.com
|
139
113
|
- olds@vmware.com
|
140
114
|
- jdsa@vmware.com
|
141
115
|
- vidya@vmware.com
|
142
116
|
- ltaylor@vmware.com
|
143
117
|
executables: []
|
144
|
-
|
145
118
|
extensions: []
|
146
|
-
|
147
119
|
extra_rdoc_files: []
|
148
|
-
|
149
|
-
files:
|
120
|
+
files:
|
150
121
|
- .gitignore
|
151
122
|
- .travis.yml
|
152
123
|
- .yardopts
|
@@ -158,51 +129,42 @@ files:
|
|
158
129
|
- cf-uaa-lib.gemspec
|
159
130
|
- lib/uaa.rb
|
160
131
|
- lib/uaa/http.rb
|
161
|
-
- lib/uaa/
|
132
|
+
- lib/uaa/info.rb
|
133
|
+
- lib/uaa/proxy_options.rb
|
162
134
|
- lib/uaa/scim.rb
|
163
135
|
- lib/uaa/token_coder.rb
|
164
136
|
- lib/uaa/token_issuer.rb
|
165
137
|
- lib/uaa/util.rb
|
166
138
|
- lib/uaa/version.rb
|
167
139
|
- spec/http_spec.rb
|
140
|
+
- spec/info_spec.rb
|
168
141
|
- spec/integration_spec.rb
|
169
|
-
- spec/misc_spec.rb
|
170
142
|
- spec/scim_spec.rb
|
171
143
|
- spec/spec_helper.rb
|
172
144
|
- spec/token_coder_spec.rb
|
173
145
|
- spec/token_issuer_spec.rb
|
174
146
|
homepage: https://github.com/cloudfoundry/cf-uaa-lib
|
175
147
|
licenses: []
|
176
|
-
|
177
148
|
post_install_message:
|
178
149
|
rdoc_options: []
|
179
|
-
|
180
|
-
require_paths:
|
150
|
+
require_paths:
|
181
151
|
- lib
|
182
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
183
153
|
none: false
|
184
|
-
requirements:
|
185
|
-
- -
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
|
188
|
-
|
189
|
-
- 0
|
190
|
-
version: "0"
|
191
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
159
|
none: false
|
193
|
-
requirements:
|
194
|
-
- -
|
195
|
-
- !ruby/object:Gem::Version
|
196
|
-
|
197
|
-
segments:
|
198
|
-
- 0
|
199
|
-
version: "0"
|
160
|
+
requirements:
|
161
|
+
- - ! '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
200
164
|
requirements: []
|
201
|
-
|
202
165
|
rubyforge_project: cf-uaa-lib
|
203
|
-
rubygems_version: 1.8.
|
166
|
+
rubygems_version: 1.8.10
|
204
167
|
signing_key:
|
205
168
|
specification_version: 3
|
206
169
|
summary: Client library for CloudFoundry UAA
|
207
170
|
test_files: []
|
208
|
-
|
data/spec/misc_spec.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Cloud Foundry 2012.02.03 Beta
|
3
|
-
# Copyright (c) [2009-2012] VMware, Inc. All Rights Reserved.
|
4
|
-
#
|
5
|
-
# This product is licensed to you under the Apache License, Version 2.0 (the "License").
|
6
|
-
# You may not use this product except in compliance with the License.
|
7
|
-
#
|
8
|
-
# This product includes a number of subcomponents with
|
9
|
-
# separate copyright notices and license terms. Your use of these
|
10
|
-
# subcomponents is subject to the terms and conditions of the
|
11
|
-
# subcomponent's license, as noted in the LICENSE file.
|
12
|
-
#++
|
13
|
-
|
14
|
-
require 'spec_helper'
|
15
|
-
require 'uaa/misc'
|
16
|
-
|
17
|
-
module CF::UAA
|
18
|
-
|
19
|
-
describe Misc do
|
20
|
-
|
21
|
-
include SpecHelper
|
22
|
-
|
23
|
-
before :all do
|
24
|
-
#Util.default_logger(:trace)
|
25
|
-
end
|
26
|
-
|
27
|
-
before do
|
28
|
-
Misc.set_request_handler do |url, method, body, headers|
|
29
|
-
url.should == target_url
|
30
|
-
method.should == :get
|
31
|
-
headers["content-type"].should be_nil
|
32
|
-
headers["accept"].gsub(/\s/, '').should =~ /application\/json;charset=utf-8/i
|
33
|
-
[200, response_body, {"content-type" => "application/json"}]
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "getting server info" do
|
38
|
-
let(:target_url) { "https://uaa.cloudfoundry.com/login" }
|
39
|
-
let(:response_body) { '{"commit_id":"12345","prompts":["one","two"]}' }
|
40
|
-
|
41
|
-
it "gets server info" do
|
42
|
-
result = Misc.server("https://uaa.cloudfoundry.com")
|
43
|
-
result["prompts"].should_not be_nil
|
44
|
-
result["commit_id"].should_not be_nil
|
45
|
-
end
|
46
|
-
|
47
|
-
context "with symbol keys" do
|
48
|
-
around do |example|
|
49
|
-
CF::UAA::Misc.symbolize_keys = true
|
50
|
-
example.call
|
51
|
-
CF::UAA::Misc.symbolize_keys = false
|
52
|
-
end
|
53
|
-
|
54
|
-
it "gets server info" do
|
55
|
-
result = Misc.server("https://uaa.cloudfoundry.com")
|
56
|
-
result[:prompts].should_not be_nil
|
57
|
-
result[:commit_id].should_not be_nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "getting UAA target" do
|
63
|
-
let(:target_url) { "https://login.cloudfoundry.com/login" }
|
64
|
-
let(:response_body) { '{"links":{"uaa":"https://uaa.cloudfoundry.com"},"prompts":["one","two"]}' }
|
65
|
-
|
66
|
-
it "gets UAA target" do
|
67
|
-
result = Misc.discover_uaa("https://login.cloudfoundry.com")
|
68
|
-
result.should == "https://uaa.cloudfoundry.com"
|
69
|
-
end
|
70
|
-
|
71
|
-
context "when there is no 'links' key present" do
|
72
|
-
let(:response_body) { '{ "prompts" : ["one","two"]} ' }
|
73
|
-
|
74
|
-
it "returns the login url" do
|
75
|
-
result = Misc.discover_uaa("https://login.cloudfoundry.com")
|
76
|
-
result.should == "https://login.cloudfoundry.com"
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "with symbol keys" do
|
81
|
-
around do |example|
|
82
|
-
CF::UAA::Misc.symbolize_keys = true
|
83
|
-
example.call
|
84
|
-
CF::UAA::Misc.symbolize_keys = false
|
85
|
-
end
|
86
|
-
|
87
|
-
it "gets UAA target" do
|
88
|
-
result = Misc.discover_uaa("https://login.cloudfoundry.com")
|
89
|
-
result.should == "https://uaa.cloudfoundry.com"
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|