-
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
Parser for public-keys value #2450
Conversation
app/domain/authentication/authn_jwt/signing_key/fetch_public_keys_signing_key.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/public_signing_keys.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/fetch_public_keys_signing_key.rb
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/public_signing_keys.rb
Outdated
Show resolved
Hide resolved
spec/app/domain/authentication/authn-jwt/signing_key/public_signing_keys_spec.rb
Outdated
Show resolved
Hide resolved
"CONJ00120E Failed to parse 'public-keys': the value is not in valid JSON format"], | ||
"When public-keys value is empty object": | ||
[{}, | ||
"CONJ00120E Failed to parse 'public-keys': Type can't be blank, Type '' is not a valid public-keys type, and Value can't be blank"], |
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 we move this string to const or to part of the loop down there
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.
I'll consider to move it to the loop once will finish all use cases...
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.
Done
config/locales/en.yml
Outdated
@@ -18,3 +18,4 @@ | |||
# | |||
# To learn more, please read the Rails Internationalization guide | |||
# available at http://guides.rubyonrails.org/i18n.html. | |||
en: |
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.
?
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.
Without it all ActiveModel
validation exceptions will be masked by i18n exception that the file is invalid.
Adding en:
to he file makes it valid and allows to receive original validation exceptions.
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.
Actually I've found that removing the file has the same effect.
Initially all lines in file are commented out #...
.
So I'm removing it instead of adding en:
to it...
context "FetchPublicKeysSigningKey call " do | ||
context "propagates false refresh value" do | ||
subject do | ||
jwks = Net::HTTP.get_response(URI("https://www.googleapis.com/oauth2/v3/certs")).body |
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.
It means that our automation will be dependent on the existence of this endpoint?
Its not better this thing be in integration test and with our own endpoint for it?
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.
I guess that there're billions things depends this endpoint in the real world :-).
Let's consider UTs as not finished yet but I'm almost sure that I'll keep it because it will be a great indicator of Conjur's compatibility to the real world...
spec/app/domain/authentication/authn-jwt/signing_key/fetch_public_keys_signing_key_spec.rb
Outdated
Show resolved
Hide resolved
32412a3
to
78673d8
Compare
app/domain/authentication/authn_jwt/signing_key/fetch_public_keys_signing_key.rb
Outdated
Show resolved
Hide resolved
errors.add(:value, "is not a valid JWKS (RFC7517)") unless | ||
@value.is_a?(Hash) && | ||
@value.key?(:keys) && | ||
@value[:keys].is_a?(Array) && |
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.
Authentication::AuthnJwt::SigningKey::PublicSigningKeys#validate_value_is_jwks calls '@value[:keys]' 2 times
module AuthnJwt | ||
module SigningKey | ||
# This class is a POJO class presents public-keys structure | ||
class PublicSigningKeys |
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.
Authentication::AuthnJwt::SigningKey::PublicSigningKeys assumes too much for instance variable '@value'
end | ||
end | ||
|
||
def validate! |
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.
Authentication::AuthnJwt::SigningKey::PublicSigningKeys has missing safe method 'validate!'
app/domain/authentication/authn_jwt/signing_key/fetch_public_keys_signing_key.rb
Outdated
Show resolved
Hide resolved
78673d8
to
837e807
Compare
app/domain/authentication/authn_jwt/signing_key/public_signing_keys.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/public_signing_keys.rb
Outdated
Show resolved
Hide resolved
app/domain/authentication/authn_jwt/signing_key/public_signing_keys.rb
Outdated
Show resolved
Hide resolved
private | ||
|
||
def validate_value_is_jwks | ||
errors.add(:value, "is not a valid JWKS (RFC7517)") unless |
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.
We have several error messages for key validation , this one is an addition ? the RFC is not to global (JSON Web Key (JWK))?
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.
The validations only for public-keys use case where the value is came from customer and is not fetched directly from keys provider
0673393
to
e97ca9c
Compare
validate(:validate_value_is_jwks, if: -> { @type == "jwks" }) | ||
|
||
def initialize(hash) | ||
raise Errors::Authentication::AuthnJwt::InvalidPublicKeys.new("the value is not in valid JSON format") unless |
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 "the value is not in valid JSON format" be moved to errors.rb
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.
Errors at the moment contains only exceptions
It's a variable part of general InvalidPublicKeys
exception text...
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
ActiveModule validation is expecting to see a dictionary in the file that masquerading original validation errors
Parses public-keys value from JSON and return a valid JWKS structure
58540cd
to
22cd7a2
Compare
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
Code Climate has analyzed commit 22cd7a2 and detected 3 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 90.9% (0.0% change). View more on Code Climate. |
Desired Outcome
There's a new
Fetch*SigningKey
family classFetchPublicKeysSigningKey
is responsible for parsingpublic-keys
value.Implemented Changes
FetchPublicKeysSigningKey
class parses thepublic-keys
valuePublicSigningKey
Connected Issue/Story
ONYX-15144
Definition of Done
Changelog
CHANGELOG update
Test coverage
changes, or
Documentation
README
s) were updated in this PRBehavior
Security