-
Notifications
You must be signed in to change notification settings - Fork 368
[Feature]: Support LDAP Authentication for Dashboard Login #4009
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
base: master
Are you sure you want to change the base?
Conversation
49085d4 to
4822529
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cea2c1a to
e986923
Compare
1ef3f63 to
9bfc2e1
Compare
|
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!"); |
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.
return the cause message as well
| cn: user1 | ||
| sn: Ldap | ||
| uid: ldaptest1 | ||
| userPassword: 12345 No newline at end of file |
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.
new line at the end
| private final PasswdAuthenticationProvider basicAuthProvider; | ||
| private final TokenAuthenticationProvider jwtAuthProvider; | ||
|
|
||
| private final PasswdAuthenticationProvider loginAuthProvider; |
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.
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")); |
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.
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); |
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.
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"); |
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.
check the user and pwd non empty
5877520 to
9644ad2
Compare
9644ad2 to
3ee9051
Compare
|
|
||
| private final PasswdAuthenticationProvider basicAuthProvider; | ||
| private final TokenAuthenticationProvider jwtAuthProvider; | ||
|
|
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.
nit: unnecessary change
| "User-defined login authentication implementation of" | ||
| + " org.apache.amoro.authentication.PasswdAuthenticationProvider"); | ||
|
|
||
| public static final ConfigOption<String> HTTP_SERVER_LOGIN_AUTH_LDAP_USERPARTTERN = |
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.
typo: PARTTERN -> PATTERN
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.
recommend: USER_PATTERN.
turboFei
left a comment
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 overall, thanks
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
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