-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[feat](Authenticator) Pluginization of Authenticator #40113
Conversation
introduces the pluginization of the Authenticator component, enabling greater flexibility and modularity within the authentication system. By refactoring the Authenticator into a pluggable SPI (Service Provider Interface), we allow for custom authentication mechanisms to be seamlessly integrated and managed. Key Changes AuthenticatorFactory Interface: Defined a new AuthenticatorFactory interface to standardize the creation of Authenticator instances. The interface includes methods to create Authenticator instances based on configuration (ConfigBase) and to return a unique identifier for each factory (e.g., "ldap", "default"). The interface also provides a method getAuthenticatorConfig() to retrieve default configuration templates, aiding in the initialization process. Factory Identifier: Each AuthenticatorFactory implementation must provide a unique identifier. This allows for easy registration and retrieval of specific Authenticator implementations based on the factory identifier. Configuration Management: The getAuthenticatorConfig() method returns a ConfigBase instance, providing a default configuration that can be used or modified before creating an Authenticator. Benefits Modularity: Authentication logic is now decoupled from the core system, making it easier to extend and maintain. Flexibility: Different authentication strategies (e.g., LDAP, default, etc.) can be easily added or swapped without altering the core codebase. Customization: Users can define custom Authenticator implementations and configure them as needed, enabling a more tailored authentication process.
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
run buildall |
TPC-H: Total hot run time: 38207 ms
|
TPC-DS: Total hot run time: 194082 ms
|
ClickBench: Total hot run time: 31.79 s
|
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
PR approved by at least one committer and no changes requested. |
PR approved by anyone and no changes requested. |
run buildall |
TPC-H: Total hot run time: 37851 ms
|
TPC-DS: Total hot run time: 193271 ms
|
ClickBench: Total hot run time: 32.47 s
|
run feut |
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
PR approved by at least one committer and no changes requested. |
## abstract introduces the pluginization of the Authenticator component, enabling greater flexibility and modularity within the authentication system. By refactoring the Authenticator into a pluggable SPI (Service Provider Interface), we allow for custom authentication mechanisms to be seamlessly integrated and managed. ## Key Changes AuthenticatorFactory Interface: This interface defines the create method, which is used to create an Authenticator instance based on initialization properties, enabling support for various authentication mechanisms. The factoryIdentifier method provides an identifier for the factory, allowing differentiation between various AuthenticatorFactory implementations (e.g., LDAP, default). Implemented Specific Authentication Factories: We have implemented factories for different authentication mechanisms (such as LDAP), providing the necessary configuration support for each. ## eg In your Maven pom.xml, add the fe-core dependency: ``` <dependency> <groupId>org.apache.doris</groupId> <artifactId>fe-core</artifactId> <version>1.2-SNAPSHOT</version> <scope>provided</scope> </dependency> ``` ``` import org.apache.doris.common.ConfigBase; public class LocalAuthenticatorFactory implements AuthenticatorFactory { @OverRide public LocalAuthenticator create(Properties initProps) { return new LocalAuthenticator(); } @OverRide public String factoryIdentifier() { return "local"; } } import java.util.HashMap; import java.util.Map; public class LocalAuthenticator implements Authenticator { private Map<String, String> userStore = new HashMap<>(); public LocalAuthenticator() { // Hardcoded usernames and passwords userStore.put("user1", "password1"); userStore.put("user2", "password2"); userStore.put("admin", "adminpass"); } @OverRide public boolean authenticate(String username, String password) { // Authenticate by checking the hardcoded user store String storedPassword = userStore.get(username); return storedPassword != null && storedPassword.equals(password); } } ``` To integrate with the SPI (Service Provider Interface) mechanism, we created a file at **src/main/resources/META-INF/services/org.apache.doris.mysql.authenticate.AuthenticatorFactory** containing **org.example.LocalAuthenticatorFactory,** which allows the system to dynamically load and utilize the LocalAuthenticatorFactory implementation. Your plugin needs to include all necessary dependencies, and it is generally recommended to package them into an Uber JAR (also known as a Fat JAR) to ensure that the plugin can run independently without additional dependency management. Once packaged, this JAR can be placed directly in the **fe/custom_lib** directory.
## abstract introduces the pluginization of the Authenticator component, enabling greater flexibility and modularity within the authentication system. By refactoring the Authenticator into a pluggable SPI (Service Provider Interface), we allow for custom authentication mechanisms to be seamlessly integrated and managed. ## Key Changes AuthenticatorFactory Interface: This interface defines the create method, which is used to create an Authenticator instance based on initialization properties, enabling support for various authentication mechanisms. The factoryIdentifier method provides an identifier for the factory, allowing differentiation between various AuthenticatorFactory implementations (e.g., LDAP, default). Implemented Specific Authentication Factories: We have implemented factories for different authentication mechanisms (such as LDAP), providing the necessary configuration support for each. ## eg In your Maven pom.xml, add the fe-core dependency: ``` <dependency> <groupId>org.apache.doris</groupId> <artifactId>fe-core</artifactId> <version>1.2-SNAPSHOT</version> <scope>provided</scope> </dependency> ``` ``` import org.apache.doris.common.ConfigBase; public class LocalAuthenticatorFactory implements AuthenticatorFactory { @OverRide public LocalAuthenticator create(Properties initProps) { return new LocalAuthenticator(); } @OverRide public String factoryIdentifier() { return "local"; } } import java.util.HashMap; import java.util.Map; public class LocalAuthenticator implements Authenticator { private Map<String, String> userStore = new HashMap<>(); public LocalAuthenticator() { // Hardcoded usernames and passwords userStore.put("user1", "password1"); userStore.put("user2", "password2"); userStore.put("admin", "adminpass"); } @OverRide public boolean authenticate(String username, String password) { // Authenticate by checking the hardcoded user store String storedPassword = userStore.get(username); return storedPassword != null && storedPassword.equals(password); } } ``` To integrate with the SPI (Service Provider Interface) mechanism, we created a file at **src/main/resources/META-INF/services/org.apache.doris.mysql.authenticate.AuthenticatorFactory** containing **org.example.LocalAuthenticatorFactory,** which allows the system to dynamically load and utilize the LocalAuthenticatorFactory implementation. Your plugin needs to include all necessary dependencies, and it is generally recommended to package them into an Uber JAR (also known as a Fat JAR) to ensure that the plugin can run independently without additional dependency management. Once packaged, this JAR can be placed directly in the **fe/custom_lib** directory.
## abstract introduces the pluginization of the Authenticator component, enabling greater flexibility and modularity within the authentication system. By refactoring the Authenticator into a pluggable SPI (Service Provider Interface), we allow for custom authentication mechanisms to be seamlessly integrated and managed. ## Key Changes AuthenticatorFactory Interface: This interface defines the create method, which is used to create an Authenticator instance based on initialization properties, enabling support for various authentication mechanisms. The factoryIdentifier method provides an identifier for the factory, allowing differentiation between various AuthenticatorFactory implementations (e.g., LDAP, default). Implemented Specific Authentication Factories: We have implemented factories for different authentication mechanisms (such as LDAP), providing the necessary configuration support for each. ## eg In your Maven pom.xml, add the fe-core dependency: ``` <dependency> <groupId>org.apache.doris</groupId> <artifactId>fe-core</artifactId> <version>1.2-SNAPSHOT</version> <scope>provided</scope> </dependency> ``` ``` import org.apache.doris.common.ConfigBase; public class LocalAuthenticatorFactory implements AuthenticatorFactory { @OverRide public LocalAuthenticator create(Properties initProps) { return new LocalAuthenticator(); } @OverRide public String factoryIdentifier() { return "local"; } } import java.util.HashMap; import java.util.Map; public class LocalAuthenticator implements Authenticator { private Map<String, String> userStore = new HashMap<>(); public LocalAuthenticator() { // Hardcoded usernames and passwords userStore.put("user1", "password1"); userStore.put("user2", "password2"); userStore.put("admin", "adminpass"); } @OverRide public boolean authenticate(String username, String password) { // Authenticate by checking the hardcoded user store String storedPassword = userStore.get(username); return storedPassword != null && storedPassword.equals(password); } } ``` To integrate with the SPI (Service Provider Interface) mechanism, we created a file at **src/main/resources/META-INF/services/org.apache.doris.mysql.authenticate.AuthenticatorFactory** containing **org.example.LocalAuthenticatorFactory,** which allows the system to dynamically load and utilize the LocalAuthenticatorFactory implementation. Your plugin needs to include all necessary dependencies, and it is generally recommended to package them into an Uber JAR (also known as a Fat JAR) to ensure that the plugin can run independently without additional dependency management. Once packaged, this JAR can be placed directly in the **fe/custom_lib** directory. (cherry picked from commit 119ea59)
1: The `defaultAuthenticator` is not initialized. When a configured authentication plugin implements the `canDea`l method and returns `false`, the `defaultAuthenticator` will be used, resulting in a login failure. The client exception message is `RROR 2013 (HY000): Lost connection to MySQL server at 'reading authorization packet', system error: 2`. This issue only affects users who use non-built-in authentication plugins that implement `canDeal` and return false under certain circumstances. apache#40113 introduced this issue
## abstract introduces the pluginization of the Authenticator component, enabling greater flexibility and modularity within the authentication system. By refactoring the Authenticator into a pluggable SPI (Service Provider Interface), we allow for custom authentication mechanisms to be seamlessly integrated and managed. ## Key Changes AuthenticatorFactory Interface: This interface defines the create method, which is used to create an Authenticator instance based on initialization properties, enabling support for various authentication mechanisms. The factoryIdentifier method provides an identifier for the factory, allowing differentiation between various AuthenticatorFactory implementations (e.g., LDAP, default). Implemented Specific Authentication Factories: We have implemented factories for different authentication mechanisms (such as LDAP), providing the necessary configuration support for each. ## eg In your Maven pom.xml, add the fe-core dependency: ``` <dependency> <groupId>org.apache.doris</groupId> <artifactId>fe-core</artifactId> <version>1.2-SNAPSHOT</version> <scope>provided</scope> </dependency> ``` ``` import org.apache.doris.common.ConfigBase; public class LocalAuthenticatorFactory implements AuthenticatorFactory { @OverRide public LocalAuthenticator create(Properties initProps) { return new LocalAuthenticator(); } @OverRide public String factoryIdentifier() { return "local"; } } import java.util.HashMap; import java.util.Map; public class LocalAuthenticator implements Authenticator { private Map<String, String> userStore = new HashMap<>(); public LocalAuthenticator() { // Hardcoded usernames and passwords userStore.put("user1", "password1"); userStore.put("user2", "password2"); userStore.put("admin", "adminpass"); } @OverRide public boolean authenticate(String username, String password) { // Authenticate by checking the hardcoded user store String storedPassword = userStore.get(username); return storedPassword != null && storedPassword.equals(password); } } ``` To integrate with the SPI (Service Provider Interface) mechanism, we created a file at **src/main/resources/META-INF/services/org.apache.doris.mysql.authenticate.AuthenticatorFactory** containing **org.example.LocalAuthenticatorFactory,** which allows the system to dynamically load and utilize the LocalAuthenticatorFactory implementation. Your plugin needs to include all necessary dependencies, and it is generally recommended to package them into an Uber JAR (also known as a Fat JAR) to ensure that the plugin can run independently without additional dependency management. Once packaged, this JAR can be placed directly in the **fe/custom_lib** directory. (cherry picked from commit 119ea59)
abstract
introduces the pluginization of the Authenticator component, enabling greater flexibility and modularity within the authentication system. By refactoring the Authenticator into a pluggable SPI (Service Provider Interface), we allow for custom authentication mechanisms to be seamlessly integrated and managed.
Key Changes
AuthenticatorFactory Interface:
This interface defines the create method, which is used to create an Authenticator instance based on initialization properties, enabling support for various authentication mechanisms.
The factoryIdentifier method provides an identifier for the factory, allowing differentiation between various AuthenticatorFactory implementations (e.g., LDAP, default).
Implemented Specific Authentication Factories:
We have implemented factories for different authentication mechanisms (such as LDAP), providing the necessary configuration support for each.
eg
In your Maven pom.xml, add the fe-core dependency:
To integrate with the SPI (Service Provider Interface) mechanism, we created a file at src/main/resources/META-INF/services/org.apache.doris.mysql.authenticate.AuthenticatorFactory containing org.example.LocalAuthenticatorFactory, which allows the system to dynamically load and utilize the LocalAuthenticatorFactory implementation.
Your plugin needs to include all necessary dependencies, and it is generally recommended to package them into an Uber JAR (also known as a Fat JAR) to ensure that the plugin can run independently without additional dependency management. Once packaged, this JAR can be placed directly in the fe/custom_lib directory.