lasdf1234 commented on code in PR #11688:
URL: https://github.com/apache/gravitino/pull/11688#discussion_r3429879620
##########
plugins/idp-basic/src/main/java/org/apache/gravitino/idp/auth/BasicAuthenticator.java:
##########
@@ -62,10 +68,31 @@ public Principal authenticateToken(byte[] tokenData) {
@Override
public void initialize(Config config) {
+ validateExtensionPackage(config);
GravitinoEnv env = GravitinoEnv.getInstance();
this.userGroupManager = IdpUserGroupManager.getInstance(config,
env.idGenerator());
}
+ /**
+ * Validates that the built-in IdP REST extension package is enabled when
Basic authentication is
+ * used.
+ *
+ * @param config The server configuration.
+ */
+ static void validateExtensionPackage(Config config) {
+ boolean idpExtensionEnabled =
+ config.get(Configs.REST_API_EXTENSION_PACKAGES).stream()
+ .anyMatch(
+ pkg ->
IdpRESTFeature.IDP_REST_EXTENSION_PACKAGE.equalsIgnoreCase(pkg.trim()));
+ if (!idpExtensionEnabled) {
+ LOG.error(
+ "'basic' in gravitino.authenticators requires
gravitino.server.rest.extensionPackages "
+ + "to include {}.",
+ IdpRESTFeature.IDP_REST_EXTENSION_PACKAGE);
+ System.exit(1);
Review Comment:
Jersey throws an exception during Servlet initialization. However, Jetty
catches the exception and still starts the connector, and the process remains
alive.
BasicAuthenticator → It would be better to change it to throw
The verification is executed in the `initialize()` function, and the
exception is passed to `main()`, causing the process to exit.
This effect is the same as the original `System.exit(1)`, which can prevent
startup and makes the unit tests simpler.
`IdpRESTFeature` → Simply changing it to `throw` is not enough
The verification is carried out in the Jersey Feature.configure(). In Jetty,
the exception is swallowed and the process does not exit; instead, 8090 becomes
503.
Originally, using System.exit(1) could actually terminate the process
immediately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]