-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ONYX-11330: Fix cache of signing key #2353
Conversation
72728a0
to
1a46ded
Compare
app/domain/authentication/authn_jwt/authentication_parameters.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/validate_and_decode/validate_and_decode_token.rb
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/vendor_configurations/configuration_jwt_generic_vendor.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/vendor_configurations/configuration_jwt_generic_vendor.rb
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments
d6a1987
to
951b371
Compare
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
951b371
to
dcc49eb
Compare
app/domain/authentication/authn_jwt/signing_key/fetch_jwks_uri_signing_key.rb
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_provider_uri_signing_key.rb
Show resolved
Hide resolved
281a1fa
to
64ad246
Compare
64ad246
to
bdd7a81
Compare
4a72688
to
c4eedc7
Compare
app/domain/authentication/authn_jwt/signing_key/fetch_cached_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/validate_and_decode/validate_and_decode_token.rb
Outdated
Show resolved
Hide resolved
@@ -66,5 +71,15 @@ def decrease_concurrent_requests | |||
) | |||
end | |||
end | |||
|
|||
def cached_key(args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a description to this method? what is this cached key? is it cached key or cache key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to cache_key and added comment
* ONYX-11330: Fix cache of signing key * Fix cache bug in authn-jwt status flow * Fixes according to PR comments Co-authored-by: Tamir Zheleznyak <[email protected]>
@@ -7,19 +7,31 @@ module ValidateAndDecode | |||
# for the 2nd validation | |||
ValidateAndDecodeToken ||= CommandClass.new( | |||
dependencies: { | |||
fetch_signing_key_from_cache: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
@@ -3,6 +3,16 @@ module AuthnJwt | |||
|
|||
ValidateStatus = CommandClass.new( | |||
dependencies: { | |||
fetch_signing_key_from_cache: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
|
||
return @cache[args] | ||
return @cache[cache_key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#call calls '@cache[cache_key]' 2 times
@@ -66,5 +71,15 @@ def decrease_concurrent_requests | |||
) | |||
end | |||
end | |||
|
|||
def cached_key(args) | |||
cache_key = args.key?(:cache_key) ? args.fetch(:cache_key) : args |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#cached_key refers to 'args' more than self (maybe move it to another class?)
end | ||
|
||
def cached_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::RateLimitedCache#cached_key refers to 'args' more than self (maybe move it to another class?)
c0119ec
to
fd5c93a
Compare
@@ -7,12 +7,23 @@ module ValidateAndDecode | |||
# for the 2nd validation | |||
ValidateAndDecodeToken ||= CommandClass.new( | |||
dependencies: { | |||
fetch_signing_key: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
@@ -3,7 +3,17 @@ module AuthnJwt | |||
|
|||
ValidateStatus = CommandClass.new( | |||
dependencies: { | |||
create_signing_key_interface: Authentication::AuthnJwt::SigningKey::CreateSigningKeyFactory.new, | |||
fetch_signing_key: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
|
||
return @cache[args] | ||
return @cache[cache_key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#call calls '@cache[cache_key]' 2 times
|
||
# Function returning cache key to store/retrieve in the cache | ||
def cache_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#cache_key refers to 'args' more than self (maybe move it to another class?)
end | ||
|
||
def cached_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::RateLimitedCache#cached_key refers to 'args' more than self (maybe move it to another class?)
fd5c93a
to
8247b0d
Compare
@@ -7,12 +7,23 @@ module ValidateAndDecode | |||
# for the 2nd validation | |||
ValidateAndDecodeToken ||= CommandClass.new( | |||
dependencies: { | |||
fetch_signing_key: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
@@ -3,7 +3,17 @@ module AuthnJwt | |||
|
|||
ValidateStatus = CommandClass.new( | |||
dependencies: { | |||
create_signing_key_interface: Authentication::AuthnJwt::SigningKey::CreateSigningKeyFactory.new, | |||
fetch_signing_key: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
|
||
return @cache[args] | ||
return @cache[cache_key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#call calls '@cache[cache_key]' 2 times
|
||
# Function returning cache key to store/retrieve in the cache | ||
def cache_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#cache_key refers to 'args' more than self (maybe move it to another class?)
end | ||
|
||
def cached_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::RateLimitedCache#cached_key refers to 'args' more than self (maybe move it to another class?)
8247b0d
to
3ed3fd9
Compare
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. | |||
|
|||
## [Unreleased] | |||
|
|||
### Fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hilagross @shulifink
Please review changelog message
@@ -2,7 +2,7 @@ module Authentication | |||
module AuthnJwt | |||
module SigningKey | |||
# Factory that returns the interface implementation of FetchSigningKey | |||
CreateSigningKeyFactory ||= CommandClass.new( | |||
CreateSigningKeyInterface ||= CommandClass.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- please match the class name to the file name (or the other way)
- What does
Interface
stand for? does this class create a Signing key object? if so it should be namedCreateSigningKey
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do change this to CreateSigningKey
, please make the corresponding changes in the rest of the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its creating a Provider object for signing key so i will rename to CreateSigningKeyProvider
3ed3fd9
to
f40ffe5
Compare
app/domain/authentication/authn_jwt/signing_key/fetch_signing_key_interface.rb
Show resolved
Hide resolved
f40ffe5
to
673317e
Compare
app/domain/authentication/authn_jwt/signing_key/create_signing_key_provider.rb
Show resolved
Hide resolved
# :reek:InstanceVariableAssumption | ||
FetchCachedSigningKey = CommandClass.new( | ||
dependencies: {}, | ||
inputs: %i[signing_key_interface] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change signing_key_interface
to signing_key_provider
in the whole PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and fix the description above
673317e
to
346f9d5
Compare
@@ -7,12 +7,23 @@ module ValidateAndDecode | |||
# for the 2nd validation | |||
ValidateAndDecodeToken ||= CommandClass.new( | |||
dependencies: { | |||
fetch_signing_key: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
@@ -3,7 +3,17 @@ module AuthnJwt | |||
|
|||
ValidateStatus = CommandClass.new( | |||
dependencies: { | |||
create_signing_key_interface: Authentication::AuthnJwt::SigningKey::CreateSigningKeyFactory.new, | |||
fetch_signing_key: ::Util::ConcurrencyLimitedCache.new( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
end | ||
|
||
def cached_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::RateLimitedCache#cached_key refers to 'args' more than self (maybe move it to another class?)
|
||
return @cache[args] | ||
return @cache[cache_key] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#call calls '@cache[cache_key]' 2 times
|
||
# Function returning cache key to store/retrieve in the cache | ||
def cache_key(args) | ||
if args.key?(:cache_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Util::ConcurrencyLimitedCache#cache_key refers to 'args' more than self (maybe move it to another class?)
Code Climate has analyzed commit 346f9d5 and detected 12 issues on this pull request. Here's the issue category breakdown:
The test coverage on the diff in this pull request is 100.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 91.0% (0.0% change). View more on Code Climate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
Bugfix for cache not working at all for saving signing key.
What ticket does this PR close?
ONYX-11330
Checklists
Change log
Test coverage
Documentation
README
s) were updated in this PR, and/or there is a follow-on issue to update docs, orAPI Changes