Skip to content

[#10960] feat(authentication): Wire basic authenticator module#10967

Open
lasdf1234 wants to merge 22 commits into
apache:mainfrom
lasdf1234:feat/local-authenticator-module-wiring
Open

[#10960] feat(authentication): Wire basic authenticator module#10967
lasdf1234 wants to merge 22 commits into
apache:mainfrom
lasdf1234:feat/local-authenticator-module-wiring

Conversation

@lasdf1234
Copy link
Copy Markdown
Contributor

@lasdf1234 lasdf1234 commented May 4, 2026

What changes were proposed in this pull request?

This PR wires the new authenticators:authenticator-basic module into the server authentication flow.

The changes include:

  • making the server module depend on authenticator-basic
  • introducing AuthenticatorType.BASIC
  • wiring gravitino.authenticators=basic to load org.apache.gravitino.server.authentication.BasicAuthenticator
  • strict basic parsing is intentional
  • adding tests for authenticator factory wiring and Basic authentication header handling
  • returning 400 Bad Request for malformed Basic authorization headers and 401 Unauthorized for missing or invalid Basic authorization headers

Why are the changes needed?

This is the module wiring work for local authentication. It enables Gravitino to recognize and load the new Basic authenticator module when gravitino.authenticators=basic, which is the foundation for the follow-up local authentication tasks.

Fix: #10960

Does this PR introduce any user-facing change?

Yes.

  • Gravitino now recognizes basic as a valid value of gravitino.authenticators
  • malformed Basic authorization headers now return 400 Bad Request
  • missing or invalid Basic authorization headers now return 401 Unauthorized

How was this patch tested?

  • added TestAuthenticatorFactory to verify basic loads BasicAuthenticator
  • added TestBasicAuthenticator to verify Basic header error handling
  • updated TestAuthenticationFilter to verify BadRequestException maps to HTTP 400
  • ran:
    • ./gradlew --no-daemon :authenticators:authenticator-basic:build
    • ./gradlew --no-daemon :server-common:test --tests org.apache.gravitino.server.authentication.TestAuthenticationFilter
    • ./gradlew --no-daemon :server:test --tests org.apache.gravitino.server.authentication.TestAuthenticatorFactory
    • ./gradlew --no-daemon classes testClasses

Copilot AI review requested due to automatic review settings May 4, 2026 14:19
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 wires a new authenticators:authenticator-basic Gradle module into Gravitino’s server authentication flow, adds AuthenticatorType.BASIC, and updates server-side HTTP status mapping so malformed Basic headers can return 400 Bad Request instead of being treated as internal errors.

Changes:

  • Adds the new authenticators:authenticator-basic module and wires it into the Gradle build (settings + server dependency).
  • Extends authenticator selection to recognize basic (AuthenticatorType.BASIC) and load org.apache.gravitino.auth.local.BasicAuthenticator.
  • Updates AuthenticationFilter to map BadRequestException to HTTP 400 and adds/updates tests around the new wiring and error mapping.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
settings.gradle.kts Includes the new authenticator-basic submodule in the Gradle build.
server/build.gradle.kts Adds a dependency from server to the new authenticator-basic module.
common/src/main/java/org/apache/gravitino/auth/AuthenticatorType.java Introduces AuthenticatorType.BASIC.
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticatorFactory.java Maps basic to the Basic authenticator class name for reflective loading.
server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java Maps BadRequestException to HTTP 400 in auth error responses.
server-common/src/test/java/org/apache/gravitino/server/authentication/TestAuthenticationFilter.java Adds a regression test asserting BadRequestException maps to HTTP 400.
server/src/test/java/org/apache/gravitino/server/authentication/TestAuthenticatorFactory.java Adds a test verifying basic loads BasicAuthenticator.
authenticators/authenticator-basic/build.gradle.kts Defines the new module build, dependencies, and test env vars.
authenticators/authenticator-basic/src/main/java/org/apache/gravitino/auth/local/BasicAuthenticator.java Implements Basic auth header parsing and exception behavior.
authenticators/authenticator-basic/src/test/java/org/apache/gravitino/auth/local/TestBasicAuthenticator.java Adds unit tests for Basic header parsing/error handling.

@lasdf1234 lasdf1234 changed the title [#10960] feat(authentication): wire basic authenticator module [#10960] feat(authentication): Wire basic authenticator module May 4, 2026
lasdf1234 and others added 4 commits May 4, 2026 22:43
…-auth-password-hashing

# Conflicts:
#	authenticators/authenticator-basic/build.gradle.kts
#	server-common/src/main/java/org/apache/gravitino/server/authentication/Argon2idPasswordHasher.java
#	server-common/src/main/java/org/apache/gravitino/server/authentication/PasswordHasher.java
#	server-common/src/main/java/org/apache/gravitino/server/authentication/PasswordHasherFactory.java
#	server-common/src/test/java/org/apache/gravitino/server/authentication/TestArgon2idPasswordHasher.java
Copy link
Copy Markdown
Contributor

@roryqi roryqi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be the first pull request. Because this relies on built-in idp.

Comment thread plugins/idp-basic/build.gradle.kts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Comments suppressed due to low confidence (1)

server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticatorFactory.java:44

  • PR description says gravitino.authenticators=basic should load org.apache.gravitino.auth.local.BasicAuthenticator, but the factory is wired to org.apache.gravitino.server.authentication.BasicAuthenticator instead. Please align the implementation/package with the intended module structure (or update the PR description/design) so users and follow-up work aren’t confused about where the Basic authenticator lives.
  public static final ImmutableMap<String, String> AUTHENTICATORS =
      ImmutableMap.of(
          AuthenticatorType.SIMPLE.name().toLowerCase(),
          SimpleAuthenticator.class.getCanonicalName(),
          AuthenticatorType.BASIC.name().toLowerCase(),
          BasicAuthenticator.class.getCanonicalName(),
          AuthenticatorType.OAUTH.name().toLowerCase(),
          OAuth2TokenAuthenticator.class.getCanonicalName(),
          AuthenticatorType.KERBEROS.name().toLowerCase(),
          KerberosAuthenticator.class.getCanonicalName());

Comment thread plugins/idp-basic/build.gradle.kts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

server/build.gradle.kts:33

  • The server now declares an implementation dependency on :authenticators:authenticator-basic, but that module currently has no main sources and the BasicAuthenticator implementation is in :server-common. This dependency is therefore unused/redundant as-is; either move the implementation into the new module (and have the factory load it from there) or remove this dependency until the module provides runtime code.
dependencies {
  implementation(project(":authenticators:authenticator-basic"))
  implementation(project(":api"))
  implementation(project(":common"))
  implementation(project(":core"))
  implementation(project(":lineage"))
  implementation(project(":server-common"))
  implementation(libs.bundles.jetty)

Comment thread plugins/idp-basic/build.gradle.kts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Comment on lines +77 to +81
throw new BadRequestException(
"Malformed Basic authorization header: username must not be empty");
}

return new UserPrincipal(userName, authData);
Comment on lines 38 to +41
AuthenticatorType.SIMPLE.name().toLowerCase(),
SimpleAuthenticator.class.getCanonicalName(),
AuthenticatorType.BASIC.name().toLowerCase(),
BasicAuthenticator.class.getCanonicalName(),
Comment on lines 27 to 34
/** Simple authentication. */
SIMPLE,

/** Authentication that uses local basic auth. */
BASIC,

/** Authentication that uses OAuth. */
OAUTH,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Subtask] Implement built-in Idp storage

3 participants