Implement AUTH command#268
Merged
buraksezer merged 18 commits intomasterfrom May 26, 2025
Merged
Conversation
Introduced functionality to handle the AUTH command, including a new `Auth` type with associated methods for command creation and parsing. Added relevant tests to ensure correct behavior and error handling for invalid arguments.
Introduced optional username/password-based authentication for client connections. Updated the configuration, command handlers, and internal server logic to enforce authentication when enabled. Includes tests and error handling for invalid credentials.
Renamed "precond" to "precondition" for clearer semantics and improved readability. Added support for setting Redis protocol version to 2 in client configuration.
Introduced an `Authentication` struct to the client configuration, enabling username/password-based authentication. This includes validation, sanitization, and integration with Redis client options. Adjusted related code to ensure proper handling of authentication settings.
Introduce an `authentication` field in the `clusterClientConfig` and a `WithCredentials` option to enable authentication via username and password. The authentication configuration is applied to the client during initialization if provided.
Added detailed comments and descriptions to structs, methods, and errors across multiple files, improving code readability and maintainability. Minor grammar corrections were also made in existing comments to ensure consistency and clarity.
Updated go-redis to v9.8.0 and golang.org/x/sync to v0.14.0 in go.mod and go.sum. These changes ensure the project uses newer versions with potential bug fixes and improvements.
Added a mechanism to propagate client authentication settings when enabled and implemented a new test suite for authentication scenarios. Fixed a semaphore acquisition error in the routing table and an issue in quorum checking logic. Minor typo correction in a log message was also applied.
Introduce an `errAuthRequired` error in the server code to signal when authentication is needed. Update configuration files to include an `authentication` section, allowing authentication to be enabled or disabled with customizable credentials. Default settings disable authentication for flexibility during setup.
Replaced direct error comparisons with `errors.Is` for better error handling. Added detailed comments and refined docstrings for several functions to enhance clarity and maintainability. Minor grammar fixes were made in descriptions.
Replaced `Enabled` with `RequirePass` and introduced `Enabled2` for improved authentication logic. This ensures consistency in configuration parsing and simplifies enabled checks by leveraging `RequirePass`.
Refactored the authentication logic to use only the `RequirePass` field, removing the `Username` and `Password` fields across the codebase. Updated related checks and tests to align with the new structure, and replaced `Enabled2` with a simplified `Enabled` method. This streamlines the configuration and reduces complexity.
Updated all references to the authentication field `RequirePass` across the codebase to `Password` for consistency and clarity. This includes changes in struct definitions, method implementations, and test configurations.
Removed usernames from the authentication flow, simplifying logic and function signatures. Updated related tests, error messages, and configuration files to reflect the password-only model.
Authentication settings have been updated to simplify the configuration by removing the disabled "username" field. Supporting functions and comments were added to manage the password-based authentication flow in the system. This change enhances clarity and prepares for future improvements.
Updated the error message text for authentication to use a capitalized format for consistency. Clarified the comment describing the `authCommandHandler` function to better convey its purpose and behavior.
Clarify the purpose of the Config struct and add documentation for the Authentication field to describe its role in securing access with authentication settings. This improves code readability and understanding for developers.
Adjusted the test error message in system_test.go to match the updated command format. Removed dead links related to Kubernetes and Docker Compose from the README, streamlining the documentation structure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR provides an implementation Redis-style
AUTHcommand.Supported by cluster client:
Embedded client is authenticated by default.
The configuration is quite simple:
Olric returns the following error if the client is unauthorized: