Skip to content

Conversation

@davedwwang
Copy link
Contributor

@davedwwang davedwwang commented Dec 11, 2025

Why are the changes needed?

The current Dashboard login uses an admin-user with a plaintext password, which is highly insecure. To enhance security, centralize user management, and align with industry standard practices, we need to switch to LDAP authentication.

Close #4008.

Brief change log

  • Introduced three new login-related configurations in AmoroManagementConf.
  • Added LdapPasswdAuthenticationProvider to support LDAP integration (implements PasswdAuthenticationProvider).
  • Updated LoginController to use PasswdAuthenticationProvider for user login validation.

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Run test locally before making a pull request

Documentation

  • Does this pull request introduce a new feature? (yes / no) yes
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented) not documented

@davedwwang davedwwang force-pushed the dev/ldap_auth branch 2 times, most recently from 49085d4 to 4822529 Compare December 11, 2025 12:36
@github-actions github-actions bot added the type:docs Improvements or additions to documentation label Dec 11, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 22.85%. Comparing base (cbdc517) to head (0be5571).
⚠️ Report is 25 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #4009      +/-   ##
============================================
+ Coverage     22.12%   22.85%   +0.72%     
- Complexity     2461     2531      +70     
============================================
  Files           445      449       +4     
  Lines         40897    41048     +151     
  Branches       5767     5784      +17     
============================================
+ Hits           9050     9380     +330     
+ Misses        31089    30859     -230     
- Partials        758      809      +51     
Flag Coverage Δ
trino 22.85% <ø> (+0.72%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@davedwwang davedwwang force-pushed the dev/ldap_auth branch 2 times, most recently from cea2c1a to e986923 Compare December 12, 2025 17:00
@davedwwang davedwwang force-pushed the dev/ldap_auth branch 2 times, most recently from 1ef3f63 to 9bfc2e1 Compare December 13, 2025 13:46
@davedwwang
Copy link
Contributor Author

hi @turboFei Would you mind reviewing this? I’d really appreciate it. Thanks!

dashboardServer.getLoginAuthProvider().authenticate(credential);
} catch (Exception e) {
LOG.error("authenticate user {} failed", user, e);
throw new RuntimeException("invalid user " + user + " or password!");
Copy link
Member

Choose a reason for hiding this comment

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

return the cause message as well

cn: user1
sn: Ldap
uid: ldaptest1
userPassword: 12345 No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

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

new line at the end

private final PasswdAuthenticationProvider basicAuthProvider;
private final TokenAuthenticationProvider jwtAuthProvider;

private final PasswdAuthenticationProvider loginAuthProvider;
Copy link
Member

Choose a reason for hiding this comment

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

how about moving the loginAuthProvider into LoginController?

String pwd = bodyParams.get("password");
if (adminUser.equals(user) && (adminPassword.equals(pwd))) {
ctx.sessionAttribute("user", new SessionInfo(adminUser, System.currentTimeMillis() + ""));
ctx.json(OkResponse.of("success"));
Copy link
Member

Choose a reason for hiding this comment

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

Seems this part of logic is missed after dashboardServer.getLoginAuthProvider().authenticate(credential);


public LdapPasswdAuthenticationProvider(Configurations conf) {
this.ldapUrl = conf.get(AmoroManagementConf.HTTP_SERVER_LOGIN_AUTH_LDAP_URL);
this.ldapUserParttern = conf.get(AmoroManagementConf.HTTP_SERVER_LOGIN_AUTH_LDAP_USERPARTTERN);
Copy link
Member

Choose a reason for hiding this comment

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

check the ldapUrl and ldapUserParttern non empty

// ok
Map<String, String> bodyParams = ctx.bodyAsClass(Map.class);
String user = bodyParams.get("user");
String pwd = bodyParams.get("password");
Copy link
Member

Choose a reason for hiding this comment

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

check the user and pwd non empty

@davedwwang davedwwang force-pushed the dev/ldap_auth branch 5 times, most recently from 9644ad2 to 3ee9051 Compare January 1, 2026 09:36
@davedwwang davedwwang requested a review from turboFei January 1, 2026 10:26

private final PasswdAuthenticationProvider basicAuthProvider;
private final TokenAuthenticationProvider jwtAuthProvider;

Copy link
Member

Choose a reason for hiding this comment

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

nit: unnecessary change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

"User-defined login authentication implementation of"
+ " org.apache.amoro.authentication.PasswdAuthenticationProvider");

public static final ConfigOption<String> HTTP_SERVER_LOGIN_AUTH_LDAP_USERPARTTERN =
Copy link
Member

Choose a reason for hiding this comment

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

typo: PARTTERN -> PATTERN

Copy link
Member

Choose a reason for hiding this comment

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

recommend: USER_PATTERN.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Member

@turboFei turboFei left a comment

Choose a reason for hiding this comment

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

LGTM overall, thanks

@zhoujinsong zhoujinsong merged commit 1198990 into apache:master Jan 8, 2026
7 checks passed
@zhoujinsong
Copy link
Contributor

Thanks for the contribution! @davedwwang
Thanks for the review! @turboFei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:ams-server Ams server module type:build type:docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support LDAP Authentication for Dashboard Login

4 participants