-
Notifications
You must be signed in to change notification settings - Fork 3
Fix to correctly validate authentication settings #222
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
base: master
Are you sure you want to change the base?
Conversation
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.
Summary of Changes
Hello @jnmt, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've implemented a fix to improve the validation of authentication settings, particularly concerning the interaction between Ledger and Auditor configurations. The primary goal is to ensure that the system correctly identifies when a private key is missing, but only under the specific condition that digital signature authentication is enabled. This change enhances the robustness of the configuration validation process and provides more accurate error messages to users.
Highlights
- Refined Authentication Validation Logic: I've refined the validation logic for authentication settings, specifically ensuring that the presence of a private key is checked only when digital signature authentication is explicitly chosen and the Auditor is enabled. This prevents incorrect validation errors in other authentication scenarios.
- Improved Configuration Documentation: I've updated the Javadoc comments in
ClientConfig.java
andLedgerConfig.java
to provide clearer guidance on authentication method configuration, emphasizing the need for consistency between client and server settings. - Enhanced Error Messaging: I've made the error message for invalid authentication settings more precise, now clearly stating that a private key is required for digital signature authentication when the Auditor is enabled.
- Expanded Test Coverage for Authentication Configurations: I've updated and added new unit tests in
LedgerConfigTest.java
to cover various authentication configuration scenarios more thoroughly, ensuring that both digital signature and HMAC authentication methods are correctly validated for missing keys under different conditions.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Pull Request Overview
This PR improves authentication setting validation in the Ledger configuration to ensure proper configuration between clients and servers. The changes fix validation logic to correctly check authentication method requirements and update related error messages and documentation.
Key changes include:
- Fixed authentication validation logic to properly check for required keys based on authentication method
- Updated error messages to be clearer and more specific
- Enhanced test coverage for authentication configuration scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
LedgerConfig.java | Fixed validation logic to check authentication method before requiring private keys and updated error message parameters |
LedgerError.java | Simplified error message to be more specific about digital signature authentication requirements |
LedgerConfigTest.java | Removed redundant test and added comprehensive tests for authentication validation scenarios |
ClientConfig.java | Updated documentation comments to clarify authentication method configuration requirements |
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.
Code Review
This pull request fixes a bug in the validation of authentication settings when the Auditor is enabled. The previous logic could allow a misconfiguration where the authentication method and the provided credentials (private key or HMAC secret) for server-to-server communication did not match. The new logic correctly enforces that the appropriate credential is provided based on the selected authentication method. The changes also include updating related error messages and tests to reflect this fix. My review includes one suggestion to improve the Javadoc for the authentication method configuration in LedgerConfig.java
to ensure clarity and prevent potential misconfigurations.
@@ -450,20 +450,6 @@ public void constructor_AuditorAndProofEnabledAndPrivateKeyGiven_ShouldConstruct | |||
assertThat(thrown).doesNotThrowAnyException(); | |||
} | |||
|
|||
@Test | |||
public void constructor_AuditorAndProofEnabledAndSecretKeyGiven_ShouldConstructProperly() { |
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.
Since the HMAC configuration always requires the server's secret key, this test should be covered by
constructor_ProofAndAuditorEnabledAndHmacConfiguredWithCipherKeyAndSecretKeyGiven_ShouldConstructProperly
.
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! Thank you!
Description
This PR fixes
LedgerConfig
validation for correct authentication settings. It also revises Javadoc based on the recent docs site changes in scalar-labs/docs-internal-scalardl#621, although it's not directly related to the bugfix.Related issues and/or PRs
Changes made
digital-signature
with the secret key for the Ledger-Auditor authentication.Checklist
Additional notes (optional)
This fix can affect the backward compatibility if users configure the server's authentication differently from the client's authentication (i.e., using both digital signature and HMAC). However, we decided to prevent this configuration, since it's a rare misconfiguration and useless when users focus on either non-repudiation or performance.
Release notes
Fixed Ledger configuration validation for correct authentication settings.