firebase-auth-rails 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: f5a423b2f5c4765679b669b3e541fd5456a323a16918db802609721bb87c373a
4
- data.tar.gz: aa2b928299b4bb2d4d13a29ba712ea4f21f4a83fefa8bf69107df5301cebd30a
3
+ metadata.gz: b925fd8bef4c907add32c7a1bbd57cd7d015d4638123a2e213fa2a1baf55e080
4
+ data.tar.gz: d91cb3d79a9b15c146db17b66eb4a18313c32b0e0be67283ae6a99f912249462
5
5
  SHA512:
6
- metadata.gz: f6d736e7dd9ff3a6ec561a5c57f36615ef69c82ca22688b0ac5fe33ebf935b1030f9bffcb08bd87ccb06198361b2d0c8fb23ecf2c66d6f91111355fee41f4a76
7
- data.tar.gz: 31f4885688484cfd118922b674c1c853ac89233458bfbab5b125e0fadf1a666c8fc3aa1f631530b5e4f508b7a2430bd83076580a6ff859cfb9cd73ae5c92e875
6
+ metadata.gz: 60e9147f6e766eb6bcc1f5bb99cb85fa2e142cd15942bdb6bf54c3178170b2473c517486dcaf4bf7a8065d1cad9061b32459e022c2d514245ce961210e3764d4
7
+ data.tar.gz: 4d0f8c2b3ec9bf579ff77fbf607fa511c6a163339027cd63a5c3155daaf15d8ba7ac19b2b430ab31d7fd2047e53bc85114237e9a6bca2d22577df991832833b6
@@ -1,57 +1,66 @@
1
- module Firebase::Auth::Authenticable
2
- def authenticate_for entity_class
3
- getter_name = "current_#{entity_class.to_s.parameterize.underscore}"
4
- define_current_entity_getter(entity_class, getter_name)
5
- public_send(getter_name)
6
- end
1
+ module Firebase
2
+ module Auth
3
+ module Authenticable
4
+ def authenticate_for entity_class
5
+ getter_name = "current_#{entity_class.to_s.parameterize.underscore}"
6
+ define_current_entity_getter(entity_class, getter_name)
7
+ public_send(getter_name)
8
+ end
7
9
 
8
- private
10
+ private
9
11
 
10
- def token
11
- params[:token] || token_from_request_headers
12
- end
12
+ def token
13
+ params[:token] || token_from_request_headers
14
+ end
13
15
 
14
- def method_missing(method, *args)
15
- prefix, entity_name = method.to_s.split('_', 2)
16
- case prefix
17
- when 'authenticate'
18
- unauthorized_entity unless authenticate_entity(entity_name)
19
- when 'current'
20
- authenticate_entity(entity_name)
21
- else
22
- super
23
- end
24
- end
16
+ def method_missing(method, *args)
17
+ prefix, entity_name = method.to_s.split('_', 2)
18
+ case prefix
19
+ when 'authenticate'
20
+ unauthorized_entity unless authenticate_entity(entity_name)
21
+ when 'current'
22
+ authenticate_entity(entity_name)
23
+ else
24
+ super
25
+ end
26
+ end
25
27
 
26
- def authenticate_entity(entity_name)
27
- if token
28
- entity_class = entity_name.camelize.constantize
29
- send(:authenticate_for, entity_class)
30
- end
31
- end
28
+ def authenticate_entity(entity_name)
29
+ if token
30
+ entity_class = entity_name.camelize.constantize
31
+ send(:authenticate_for, entity_class)
32
+ end
33
+ end
32
34
 
33
- def unauthorized_entity
34
- head(:unauthorized)
35
- end
35
+ def unauthorized_entity
36
+ head(:unauthorized)
37
+ end
36
38
 
37
- def token_from_request_headers
38
- unless request.headers['Authorization'].nil?
39
- request.headers['Authorization'].split.last
40
- end
41
- end
39
+ def token_from_request_headers
40
+ unless request.headers['Authorization'].nil?
41
+ # FIXME: bearer
42
+ request.headers['Authorization'].split.last
43
+ end
44
+ end
42
45
 
43
- def define_current_entity_getter entity_class, getter_name
44
- unless self.respond_to?(getter_name)
45
- memoization_var_name = "@_#{getter_name}"
46
- self.class.send(:define_method, getter_name) do
47
- unless instance_variable_defined?(memoization_var_name)
48
- # FIXME: change model class
49
- # FIXME: error handling
50
- _token = Firebase::Auth::Token.new(token: token)
51
- current = _token.entity_for(entity_class)
52
- instance_variable_set(memoization_var_name, current)
46
+ def define_current_entity_getter entity_class, getter_name
47
+ unless self.respond_to?(getter_name)
48
+ memoization_var_name = "@_#{getter_name}"
49
+ self.class.send(:define_method, getter_name) do
50
+ unless instance_variable_defined?(memoization_var_name)
51
+ # FIXME: error handling
52
+ firebase_auth_token = Firebase::Auth::Token.new(token: token)
53
+ current =
54
+ begin
55
+ firebase_auth_token.entity_for(entity_class)
56
+ rescue
57
+ nil
58
+ end
59
+ instance_variable_set(memoization_var_name, current)
60
+ end
61
+ instance_variable_get(memoization_var_name)
62
+ end
53
63
  end
54
- instance_variable_get(memoization_var_name)
55
64
  end
56
65
  end
57
66
  end
@@ -1,7 +1,7 @@
1
1
  module Firebase
2
2
  module Auth
3
3
  module Rails
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
6
6
  end
7
7
  end
@@ -9,7 +9,7 @@ module Firebase
9
9
  @token = token
10
10
  @payload = FirebaseIdToken::Signature.verify(token)
11
11
  # user not found or decode error
12
- raise StandardError, 'decode error' if @payload.nil?
12
+ # raise StandardError, 'decode error' if @payload.nil?
13
13
  end
14
14
 
15
15
  def entity_for(entity_class)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebase-auth-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - penguinwokrs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-20 00:00:00.000000000 Z
11
+ date: 2018-07-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-retry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rails
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +108,26 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  version: 2.3.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: jwt
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.1.0
118
+ - - "~>"
119
+ - !ruby/object:Gem::Version
120
+ version: '2.1'
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: 2.1.0
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '2.1'
97
131
  description: Description of Firebase::Auth::Rails.
98
132
  email:
99
133
  - dev.and.penguin@gmail.com