Skip to content

Commit

Permalink
Merge pull request #36 from fschuindt/fix/multi_thread_caching
Browse files Browse the repository at this point in the history
fix: Multi thread caching by reverting PR #33
  • Loading branch information
fschuindt authored Aug 15, 2022
2 parents 74ffb26 + 440b18f commit 184b9f3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.5.1] - 2022-08-15

### Fixed
- "[New caching doesn't honor request! calls](https://github.com/fschuindt/firebase_id_token/issues/35)", by reverting "[Caching certificates on memory.](https://github.com/fschuindt/firebase_id_token/pull/33)", PR #33.

## [2.5.0] - 2022-04-13

### Fixed
Expand Down Expand Up @@ -109,6 +114,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.1.0] - 2017-04-23
*Version removed.*

[2.5.1]: https://github.com/fschuindt/firebase_id_token/compare/2.5.0...2.5.1
[2.5.0]: https://github.com/fschuindt/firebase_id_token/compare/2.4.0...2.5.0
[2.4.0]: https://github.com/fschuindt/firebase_id_token/compare/2.3.2...2.4.0
[2.3.2]: https://github.com/fschuindt/firebase_id_token/compare/2.3.1...2.3.2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ gem install firebase_id_token

or in your Gemfile
```
gem 'firebase_id_token', '~> 2.5.0'
gem 'firebase_id_token', '~> 2.5.1'
```
then
```
Expand Down
15 changes: 1 addition & 14 deletions lib/firebase_id_token/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,20 +78,7 @@ def initialize(jwt_token, raise_error: false)

# @see Signature.verify
def verify
var_name = :_firebase_id_token_cert
Thread.current[var_name] ||= {
cert: nil,
expires_at: Time.now.utc - 1
}

if Thread.current[var_name][:expires_at] <= Time.now.utc
Thread.current[var_name] = {
cert: firebase_id_token_certificates.find(@kid, raise_error: @raise_error),
expires_at: Time.now.utc + firebase_id_token_certificates.ttl
}
end

certificate = Thread.current[var_name][:cert]
certificate = firebase_id_token_certificates.find(@kid, raise_error: @raise_error)
return unless certificate

payload = decode_jwt_payload(@jwt_token, certificate.public_key)
Expand Down
4 changes: 0 additions & 4 deletions lib/firebase_id_token/testing/certificates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ def self.read_jwt_file
)
)
end

def self.ttl
10
end
end
end
end
2 changes: 1 addition & 1 deletion lib/firebase_id_token/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FirebaseIdToken
VERSION = '2.5.0'
VERSION = '2.5.1'
end

0 comments on commit 184b9f3

Please sign in to comment.