aptible-rails 0.6.13 → 0.7.0

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
  SHA1:
3
- metadata.gz: f28cb0873976e088fd11afe512af9a7f959e3cbd
4
- data.tar.gz: 4739e33daa19441251a0dd9a830a0e1634ac94aa
3
+ metadata.gz: 2c8dc1d684786ad45a025fc08834c374dbdbc6bb
4
+ data.tar.gz: 1968ca83e38e726bf13a141b2af1e62a785d3290
5
5
  SHA512:
6
- metadata.gz: 1f6363260c22720e41faab63e75e1856404c6f6434310f6a374049779d061adc0cb4a6b9eba821b89fabdc74e9709200fee583d613bcff066f9d5c08088edee2
7
- data.tar.gz: dad98350604c78e7f10b5b916d3d9d53d1d0040aa68891c18e942cb28022c8ecaceff237e2ab01724f317af65fbef3ce0059693308ee008ed808f80d6bd01131
6
+ metadata.gz: ce87fae770f383724c238363b355832ee9a6b85153645a880be4e0fca2824eca943fae82ad9f6d0fad0c15776b87435b4716c5bb48a8ffca891f8fc37f76ecca
7
+ data.tar.gz: 397804731e86db0a48e1244741050e7f251b3a62c71eaae197161774833ef0d371fb12059ae3faa6323a36af849115fc7e7b954115d49b2b5a95cc0753612201
@@ -27,8 +27,11 @@ module Aptible
27
27
  def current_organization
28
28
  return @current_organization if @current_organization
29
29
  url = read_shared_cookie(:organization_url)
30
- @current_organization = Aptible::Auth::Organization.find_by_url(
31
- url, token: session_token) if url
30
+ if url
31
+ @current_organization = Aptible::Auth::Organization.find_by_url(
32
+ url, token: session_token
33
+ )
34
+ end
32
35
  @current_organization ||= default_organization
33
36
 
34
37
  rescue HyperResource::ClientError => e
@@ -42,7 +45,7 @@ module Aptible
42
45
 
43
46
  def production_apps
44
47
  return @production_apps if @production_apps
45
- accounts = Aptible::Api::Account.all(token: service_token)
48
+ accounts = Aptible::Api::Account.all(token: session_token)
46
49
  accounts = accounts.select do |account|
47
50
  next unless account.type == 'production'
48
51
  next unless account.organization == current_organization
@@ -74,11 +77,6 @@ module Aptible
74
77
  redirect_to Aptible::Rails.configuration.login_url unless current_user
75
78
  end
76
79
 
77
- # before_action :ensure_service_token
78
- def ensure_service_token
79
- redirect_to aptible_login_url unless service_token
80
- end
81
-
82
80
  # before_action :ensure_compliance_plan
83
81
  def ensure_compliance_plan
84
82
  unless current_organization &&
@@ -97,7 +95,7 @@ module Aptible
97
95
 
98
96
  def criteria
99
97
  @criteria ||= Aptible::Gridiron::Criterion.where(
100
- token: service_token,
98
+ token: session_token,
101
99
  organization: current_organization
102
100
  )
103
101
  end
@@ -105,46 +103,9 @@ module Aptible
105
103
  def compliance_alerts
106
104
  return @compliance_alerts if @compliance_alerts
107
105
  @compliance_alerts = ComplianceAlertCollection.new(
108
- criteria, production_apps, organization_users
109
- ).all
110
- end
111
-
112
- def service_token
113
- return unless session_token && session_token.session
114
- return @service_token if @service_token
115
-
116
- @service_token = cached_service_token(session_token)
117
- if Fridge::AccessToken.new(@service_token).valid?
118
- @service_token
119
- else
120
- @service_token = cached_service_token(session_token,
121
- force: true) || session_token
122
- end
123
- end
124
-
125
- def cached_service_token(session_token, options = {})
126
- fail 'Token must be a service token' unless session_token.session
127
- cache_key = "service_token:#{session_token.session}"
128
- ::Rails.cache.fetch(cache_key, options) do
129
- swap_session_token(session_token)
130
- end
131
- end
132
-
133
- # rubocop:disable MethodLength
134
- def swap_session_token(session_token)
135
- Aptible::Auth::Token.create(
136
- client_id: Aptible::Rails.configuration.client_id,
137
- client_secret: Aptible::Rails.configuration.client_secret,
138
- subject: session_token.serialize
139
- ).access_token
140
- rescue OAuth2::Error => e
141
- if e.code == 'unauthorized'
142
- nil
143
- else
144
- raise 'Could not swap session token, check Client#privileged?'
145
- end
106
+ criteria, production_apps, organization_users
107
+ ).all
146
108
  end
147
- # rubocop:enable MethodLength
148
109
 
149
110
  def organization_url(id)
150
111
  "#{dashboard_url}/organizations/#{id}"
@@ -157,7 +118,7 @@ module Aptible
157
118
  def criterion_by_handle(handle)
158
119
  Aptible::Gridiron::Criterion.where(
159
120
  handle: handle.to_s,
160
- token: service_token,
121
+ token: session_token,
161
122
  organization: current_organization
162
123
  ).first
163
124
  end
@@ -1,5 +1,5 @@
1
1
  module Aptible
2
2
  module Rails
3
- VERSION = '0.6.13'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aptible-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.13
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Macreery
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-29 00:00:00.000000000 Z
11
+ date: 2015-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_config
@@ -221,7 +221,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
221
  version: '0'
222
222
  requirements: []
223
223
  rubyforge_project:
224
- rubygems_version: 2.4.3
224
+ rubygems_version: 2.2.2
225
225
  signing_key:
226
226
  specification_version: 4
227
227
  summary: Rails helpers for Aptible service applications