firebase_id_token 1.2.1 → 1.2.2

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: 10e2e87315caff74a53a4899cc088d737e8d7b5a
4
- data.tar.gz: 823c6b4809fc6c8b998d7a5e76f7ba978464b8c0
3
+ metadata.gz: fc79c09ea6648ca49fc769f921f9c8a15997b9de
4
+ data.tar.gz: d7881b68a3d41570c38cbb234f5386b3c9b73668
5
5
  SHA512:
6
- metadata.gz: 301165fd8085b562c37c0e6440655886ca0abe310a9d3a57a46770a7317159db476a396f7d2a4253e5c0854eeb14ee5290291374e8587697f4849467b52712f0
7
- data.tar.gz: 8c46a36573cee0c8d6463768566aa58995e3b544ecf70c9aa8b0708047b9fa510e6d983b2aa12547329bd153e4e74f5e1a179f05040f934abf7ad1ef153ebbba
6
+ metadata.gz: ea3eed1f06ae7de070734edc01b2461ed7dae039301e1498d58b922b1100761c200f385f9b083a5762ec0c97d48c800a2e38f7936ed04069ed91979c91d9b74c
7
+ data.tar.gz: 86d0164fb11c3803c2b1c9913c9bb971d355a93fd515d106ea8fbef11cf5d5bd7c305104ada72fb0505c4ced8cb7966dcc58cac85ce7b7c51228ddc63860abbe
data/README.md CHANGED
@@ -34,7 +34,7 @@ gem install firebase_id_token
34
34
 
35
35
  or in your Gemfile
36
36
  ```
37
- gem 'firebase_id_token', '~> 1.2.1'
37
+ gem 'firebase_id_token', '~> 1.2.2'
38
38
  ```
39
39
  then
40
40
  ```
@@ -46,7 +46,6 @@ bundle install
46
46
  It's needed to set up your Firebase Project ID.
47
47
 
48
48
  If you are using Rails, this should probably go into `config/initializers/firebase_id_token.rb`.
49
-
50
49
  ```ruby
51
50
  FirebaseIdToken.configure do |config|
52
51
  config.project_ids = ['your-firebase-project-id']
@@ -114,20 +113,49 @@ FirebaseIdToken::Certificates.find('ec8f292sd30224afac5c55540df66d1f999d')
114
113
 
115
114
  #### Downloading in Rails
116
115
 
117
- If you are using Rails it's preferred that you download the certificates in a background job, you can use [ActiveJob](http://guides.rubyonrails.org/active_job_basics.html) in this case.
118
- ```ruby
119
- class RequestCertificatesJob < ApplicationJob
120
- queue_as :default
116
+ If you are using Rails, it's clever to download certificates in a cron task, you can use [whenever](https://github.com/javan/whenever).
117
+
118
+ **Example**
119
+
120
+ *Read whenever's guide on how to set it up.*
121
121
 
122
- def perform
123
- FirebaseIdToken::Certificates.request_anyway
122
+ Create your task in `lib/tasks/firebase.rake`:
123
+ ```ruby
124
+ namespace :firebase do
125
+ namespace :certificates do
126
+ desc "Request Google's x509 certificates when Redis is empty"
127
+ task request: :environment do
128
+ FirebaseIdToken::Certificates.request
129
+ end
130
+
131
+ desc "Request Google's x509 certificates and override Redis"
132
+ task request_anyway: :environment do
133
+ FirebaseIdToken::Certificates.request_anyway
134
+ end
124
135
  end
125
136
  end
126
137
  ```
127
138
 
128
- Then set it as a cron job, I recommend running it once every hour or every 30 minutes, it's up to you. Normally the certificates expiration time is around 5 to 6 hours, but it's good to perform it in a small fraction of this time.
139
+ And in your `config/schedule.rb` you might have:
140
+ ```ruby
141
+ every 1.hour do
142
+ rake 'firebase:certificates:request_anyway'
143
+ end
144
+ ```
145
+
146
+ Then:
147
+ ```
148
+ $ whenever --update-crontab
149
+ ```
150
+
151
+ I recommend running it once every hour or every 30 minutes, it's up to you. Normally the certificates expiration time is around 4 to 6 hours, but it's good to perform it in a small fraction of this time.
152
+
153
+ When developing and testing you should just run the task:
154
+ ```
155
+ $ rake firebase:certificates:request
156
+ ```
129
157
 
130
- You can use [whenever](https://github.com/javan/whenever) to do this.
158
+ *And remember, you need the Redis server to be running.*
131
159
 
132
160
  ### Verifying Tokens
133
161
 
@@ -157,8 +157,8 @@ module FirebaseIdToken
157
157
  end
158
158
 
159
159
  def ttl
160
- ttl = DateTime.parse(@request.headers['expires']).
161
- to_time.to_i - Time.now.to_i
160
+ cache_control = @request.headers['cache-control']
161
+ ttl = cache_control.match(/max-age=([0-9]+)/).captures.first.to_i
162
162
 
163
163
  if ttl > 3600
164
164
  ttl
@@ -1,3 +1,3 @@
1
1
  module FirebaseIdToken
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebase_id_token
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Schuindt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-27 00:00:00.000000000 Z
11
+ date: 2017-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler