cfoundry 0.3.12 → 0.3.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -180,7 +180,7 @@ module CFoundry::V1
180
180
 
181
181
 
182
182
  # Retreive all of the current user's applications.
183
- def apps
183
+ def apps(depth = 1, query = {})
184
184
  @base.apps.collect do |json|
185
185
  App.new(json[:name], self, json)
186
186
  end
@@ -201,7 +201,7 @@ module CFoundry::V1
201
201
  end
202
202
 
203
203
  # Retrieve all of the current user's services.
204
- def service_instances
204
+ def service_instances(depth = 1, query = {})
205
205
  @base.services.collect do |json|
206
206
  ServiceInstance.new(json[:name], self, json)
207
207
  end
@@ -1,3 +1,5 @@
1
+ require "base64"
2
+
1
3
  require "cfoundry/v2/base"
2
4
 
3
5
  require "cfoundry/v2/app"
@@ -62,8 +64,10 @@ module CFoundry::V2
62
64
 
63
65
  # The currently authenticated user.
64
66
  def current_user
65
- if user = info[:user]
66
- user(user)
67
+ if guid = token_data[:user_id]
68
+ user = user(guid)
69
+ user.emails = [{ :value => token_data[:email] }]
70
+ user
67
71
  end
68
72
  end
69
73
 
@@ -185,5 +189,21 @@ module CFoundry::V2
185
189
  json)
186
190
  end
187
191
  end
192
+
193
+ private
194
+
195
+ # grab the metadata from a token that looks like:
196
+ #
197
+ # bearer (base64 ...)
198
+ def token_data
199
+ tok = Base64.decode64(@base.token.sub(/^bearer\s+/, ""))
200
+ tok.sub!(/\{.+?\}/, "") # clear algo
201
+ JSON.parse(tok[/\{.+?\}/], :symbolize_names => true)
202
+
203
+ # normally i don't catch'em all, but can't expect all tokens to be the
204
+ # proper format, so just silently fail as this is not critical
205
+ rescue
206
+ {}
207
+ end
188
208
  end
189
209
  end
@@ -1,4 +1,4 @@
1
1
  module CFoundry # :nodoc:
2
2
  # CFoundry library version number.
3
- VERSION = "0.3.12"
3
+ VERSION = "0.3.13"
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfoundry
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 12
10
- version: 0.3.12
9
+ - 13
10
+ version: 0.3.13
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alex Suraci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-25 00:00:00 Z
18
+ date: 2012-07-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rest-client