-
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
Authn jwt all signing key settings #2461
Conversation
app/domain/authentication/authn_jwt/signing_key/signing_key_settings_builder.rb
Show resolved
Hide resolved
return provider_uri if provider_uri | ||
end | ||
|
||
def signing_key_settings_type |
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.
Method signing_key_settings_type
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
@@ -0,0 +1,52 @@ | |||
module Authentication | |||
module AuthnJwt | |||
module SigningKey |
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 has no descriptive comment
8354e5e
to
54d0c93
Compare
return unless !jwks_uri && !provider_uri && !public_keys | ||
|
||
raise Errors::Authentication::AuthnJwt::InvalidSigningKeySettings, | ||
"One of #{JWKS_URI_RESOURCE_NAME}, #{PUBLIC_KEYS_RESOURCE_NAME}, and #{PROVIDER_URI_RESOURCE_NAME} have to be defined" |
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 this raises a good question if to leave the provider uri, as the customer will see it in the error, and will wonder what it is...
maybe we can remove it from the error?
will verify with Sharon.
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 think that we cannot remove it because it may turn troubleshooting to a nightmare...
return unless jwks_uri && public_keys && provider_uri | ||
|
||
raise Errors::Authentication::AuthnJwt::InvalidSigningKeySettings, | ||
"#{JWKS_URI_RESOURCE_NAME}, #{PUBLIC_KEYS_RESOURCE_NAME}, and #{PROVIDER_URI_RESOURCE_NAME} cannot be define simultaneously" |
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.
@shulifink can you pls review the text?
these variables cannot be defined togethe.
return unless jwks_uri && provider_uri | ||
|
||
raise Errors::Authentication::AuthnJwt::InvalidSigningKeySettings, | ||
"#{JWKS_URI_RESOURCE_NAME} and #{PROVIDER_URI_RESOURCE_NAME} cannot be define simultaneously" |
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.
Cant we move this template 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.
Actually errors.rb contains only TrackableErrorClass
instances so moving plain text messages to it feels me not right.
But I'll move those texts to consts of the same class
54d0c93
to
3d446df
Compare
The class validates signing key parameters and creates a valid SigningKeySettings object from them Two new parameters cert_store and signing_keys are added to the SigningKeySettings class
3d446df
to
ba79c6f
Compare
@@ -0,0 +1,133 @@ | |||
module Authentication | |||
module AuthnJwt | |||
module SigningKey |
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 has 8 constants
check_authenticator_secret_exists: Authentication::Util::CheckAuthenticatorSecretExists.new, | ||
fetch_authenticator_secrets: Authentication::Util::FetchAuthenticatorSecrets.new | ||
}, | ||
inputs: %i[authenticator_input] |
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.
Maybe consider using delgators for
accout, service_id, authenticator_name
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.
From one point of view let it be.
From other do we have some rule of thumb when to use delegators?
module AuthnJwt | ||
module SigningKey | ||
|
||
NO_SIGNING_KEYS_SOURCE = "One of #{JWKS_URI_RESOURCE_NAME}, #{PUBLIC_KEYS_RESOURCE_NAME}, and #{PROVIDER_URI_RESOURCE_NAME} have to be defined".freeze |
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 it sit in consts or 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.
It's too specific from my point of view.
Nobody else is using the same consts so there's no reason to split it to other files.
As I mentioned before errors.rb is a container for exceptions, not for error messages.
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
Variables values related to signing keys fetching from one side and values validation and the settings object creation are split to two classes (parameters fetcher and settings builder) both classes are used by CreateSigningKeyProvider class
ba79c6f
to
5fabe9a
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 5fabe9a 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 91.2% (0.1% change). View more on Code Climate. |
Desired Outcome
JWT Authenticator is able to relate to two new variables
ca-cert
andpublic-keys
. Both variables are related to signing keys settings area. Authenticator validates validity of variables permutations.It's not full variables integration yet, so this PR does not change the behavior in this matter.
Implemented Changes
Responsibility for fetching variables values and validating and building signing key settings object is now split between two classes:
FetchSigningKeyParametersFromVariables
andSigningKeySettingsBuilder
.Both classes are dependency of the
CreateSigningKeyProvider
class, signing key providers are using signing key settings.General and non informative
InvalidUriConfiguration
(CONJ00086E
) error is replaced by informativeInvalidSigningKeySettings
(CONJ00122E
) one, seespec/app/domain/authentication/authn-jwt/signing_key/signing_key_settings_builder_spec.rb
file for the list of inputs and output error messages.Connected Issue/Story
ONYX-15140
Definition of Done
Changelog
CHANGELOG update
Test coverage
changes, or
Documentation
README
s) were updated in this PRBehavior
Security