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 +4 -4
- data/README.md +38 -10
- data/lib/firebase_id_token/certificates.rb +2 -2
- data/lib/firebase_id_token/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc79c09ea6648ca49fc769f921f9c8a15997b9de
|
4
|
+
data.tar.gz: d7881b68a3d41570c38cbb234f5386b3c9b73668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
118
|
-
|
119
|
-
|
120
|
-
|
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
|
-
|
123
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
161
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2017-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|