| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
fe-authentication-spi defines the plugin contract for authentication in Doris FE.
Plugin authors implement:
Plugins are discovered via Java ServiceLoader.
public interface AuthenticationPlugin extends Plugin {
String name();
default String description() { ... }
boolean supports(AuthenticationRequest request);
default boolean requiresClearPassword() { return false; }
default boolean supportsMultiStep() { return false; }
AuthenticationResult authenticate(
AuthenticationRequest request,
AuthenticationIntegration integration
) throws AuthenticationException;
default void validate(AuthenticationIntegration integration) throws AuthenticationException { }
default void initialize(AuthenticationIntegration integration) throws AuthenticationException { }
default void reload(AuthenticationIntegration integration) throws AuthenticationException {
initialize(integration);
}
default void close() { }
}Result/exception contract:
public interface AuthenticationPluginFactory extends PluginFactory {
String name();
AuthenticationPlugin create();
}Factory guidance in this repository:
public final class CustomAuthPlugin implements AuthenticationPlugin {
@Override
public String name() {
return "custom-auth";
}
@Override
public boolean supports(AuthenticationRequest request) {
return CredentialType.OAUTH_TOKEN.equalsIgnoreCase(request.getCredentialType());
}
@Override
public AuthenticationResult authenticate(
AuthenticationRequest request,
AuthenticationIntegration integration) throws AuthenticationException {
byte[] credential = request.getCredential();
if (credential == null || credential.length == 0) {
return AuthenticationResult.failure("Token is required");
}
boolean ok = validateToken(credential, integration);
if (!ok) {
return AuthenticationResult.failure("Invalid token");
}
return AuthenticationResult.success(
BasicPrincipal.builder()
.name(request.getUsername())
.authenticator(integration.getName())
.build());
}
private boolean validateToken(byte[] token, AuthenticationIntegration integration) {
return true;
}
}Factory and ServiceLoader registration:
public final class CustomAuthPluginFactory implements AuthenticationPluginFactory {
@Override
public String name() {
return "custom-auth";
}
@Override
public AuthenticationPlugin create() {
return new CustomAuthPlugin();
}
}src/main/resources/META-INF/services/org.apache.doris.authentication.spi.AuthenticationPluginFactory:
com.example.auth.CustomAuthPluginFactory
V1 runtime notes:
cd fe-authentication-spi
mvn test| Back | FazBrowse Home | New Git URL |