auth_passport_checkpoint 0.0.17.1 → 0.0.17.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZmY4OWFhMDBmNjRkYmEwODUwNTk1YzJhN2MwMDk4MzQyNzczNjRmMg==
4
+ OTFlNmM5ZTQyMTdjNDA1YzZmYjY4MjY1YTllNWJiNGYxZWVmM2I0Yg==
5
5
  data.tar.gz: !binary |-
6
- ZjljNzMwYzQxMjAxNzNiNzMxZDBkM2NiMGQzZGE2ODE3MWQwMTQxNQ==
6
+ ZDk0MDE5ZmE5ZmZjMjA0ZjBlZjA0OGUwOTEwZTc3YzZiYjlmYzNhMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YWM4ZWU5NzMxNjExNGVhY2IyZmFlNjI4NGZjNDNiZjBkNzFmNGU0YzMyNGQz
10
- MzllNTkyNWNlYzBkYmRjM2RjZWJmZjE2MzVhOTQ2NzdiZTUwY2U3Y2IwYjQ2
11
- NzMwNzQ4MTk2YTk3ZmIyZTc1YWJkMjc3YjIyZjgwYTk0YjNlZmM=
9
+ ZGJmYzFlMWEyNzVlMTcxZGJlYzAzZWFhMTNiYTZkNmNjYWM1MjIzOTBmNzVi
10
+ NTkyNmQ2MjVjZTRhMjQ2MjQyOWNlODMxMDEyMmI5OGUxYTZjMmRkZmM5OTVm
11
+ N2VmOTE1ZmMzYWY3M2Q1YmQzNzUzZjgzMjA1ZGJmODJiODljNGY=
12
12
  data.tar.gz: !binary |-
13
- NTgzNWFlMzZkMzY5NGQ4NWEwMTdhMTRmYmVkYjJhNGMzYjkyMTJhNTUwMGFh
14
- YzE1NTZjYmIzNTk3MTdhMmQwODRjYjllNGJjOGRjNWY5N2E3ZmEzMGFkOTY1
15
- YTZiMjYxY2FkYTRjNjNmYTAzMDdmYzFlOGEzYTA2MjA2NDc4Zjc=
13
+ Nzg5YTA4NzAzZGJhNjg3ZmU1MTU0NDBmNjgyMTE1M2Y4ZTgzZDE4OGIwMGY2
14
+ ZmQwNjIyZTBhNWMxOTc3NTY4Y2U3NGFjNDA5ZjIwZDgxZjBkMWY2NTlhODgy
15
+ YTMzYzVhODNlNzAyYjQ2YzU3OTBkMDg2Nzk1ODZmOTM1OGJiMWY=
@@ -14,9 +14,16 @@ module AuthPassportCheckpoint
14
14
  @@current_user_url ||= "http://localhost:3000/auth_passport_office/user"
15
15
  end
16
16
 
17
+ mattr_accessor :redis_connection
18
+ def self.redis_connection
19
+ @@redis_connection ||= @@redis_config ? Redis.new(@@redis_config) : nil
20
+ end
21
+
22
+ mattr_accessor :redis_cache_expiration
17
23
  def self.configure(args = {})
18
24
  @@is_intermediary_api = args[:is_intermediary_api] || false
19
25
  @@current_user_url = args[:current_user_url]
20
- end
21
-
26
+ @@redis_config = args[:redis_config]
27
+ @@redis_cache_expiration = args[:redis_cache_expiration] || 360
28
+ end
22
29
  end
@@ -0,0 +1,23 @@
1
+ module AuthPassportCheckpoint
2
+ class Booster
3
+
4
+ class << self
5
+ def redis
6
+ AuthPassportCheckpoint.redis_connection
7
+ end
8
+
9
+ def namespaced_key key
10
+ "#{key} - AuthPassportCheckpoint_Booster"
11
+ end
12
+
13
+ def get key
14
+ val = redis.get(key)
15
+ val ? JSON.parse(val) : nil
16
+ end
17
+
18
+ def set key, val
19
+ redis.set key, val.try(:to_json).try(:to_s), ex: AuthPassportCheckpoint.redis_cache_expiration
20
+ end
21
+ end
22
+ end
23
+ end
@@ -11,6 +11,7 @@ module AuthPassportCheckpoint
11
11
  require 'auth_passport_checkpoint/frontend_app/access_token_helper'
12
12
  require 'auth_passport_checkpoint/intermediary_api/access_token_helper'
13
13
  require 'auth_passport_checkpoint/intermediary_api/current_user_helper'
14
+ require 'auth_passport_checkpoint/booster'
14
15
  require 'auth_passport_checkpoint/signed_request'
15
16
 
16
17
 
@@ -14,6 +14,8 @@ module AuthPassportCheckpoint
14
14
  end
15
15
 
16
16
  def current_user
17
+ return @current_user if @current_user
18
+
17
19
  result = signed_request_result(AuthPassportCheckpoint.current_user_url)
18
20
  @current_user ||= result.try(:[],:error) ? nil : result
19
21
  end
@@ -2,13 +2,12 @@ module SignedRequestHelper
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  def signed_request_result(request_uri, args = {})
5
- result = signed_request(request_uri, args = {}).result
6
- result
7
- end
8
-
9
- def signed_request(request_uri, args = {})
10
- request_params = (args[:params] || {}).merge({access_token: current_access_token})
11
- AuthOriginControl::SignedRequest.new(request_uri, args.merge({:payload => request_params}))
5
+ if kurrent_user = AuthPassportCheckpoint::Booster.get(current_access_token)
6
+ kurrent_user
7
+ else
8
+ request_params = (args[:params] || {}).merge({access_token: current_access_token})
9
+ AuthPassportCheckpoint::Booster.set current_access_token, AuthOriginControl::SignedRequest.new(request_uri, args.merge({:payload => request_params})).try(:result)
10
+ end
12
11
  end
13
12
  end
14
13
 
@@ -1,3 +1,3 @@
1
1
  module AuthPassportCheckpoint
2
- VERSION = "0.0.17.1"
2
+ VERSION = "0.0.17.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth_passport_checkpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17.1
4
+ version: 0.0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - NicoArboagst
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-01 00:00:00.000000000 Z
11
+ date: 2013-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.0.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: redis
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 3.0.0
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: mysql2
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +94,7 @@ files:
80
94
  - app/helpers/auth_passport_checkpoint/application_helper.rb
81
95
  - app/views/layouts/auth_passport_checkpoint/application.html.erb
82
96
  - config/routes.rb
97
+ - lib/auth_passport_checkpoint/booster.rb
83
98
  - lib/auth_passport_checkpoint/engine.rb
84
99
  - lib/auth_passport_checkpoint/frontend_app/access_token_helper.rb
85
100
  - lib/auth_passport_checkpoint/intermediary_api/access_token_helper.rb