Skip to content

Conversation

aabharti-visa
Copy link
Contributor

It was observed that LDAP groups were not getting fetched for user via /login API.

This PR involves changes for /login API via LDAP authentication. The changes includes validating user credentials for /login API via LDAP provider and then fetching groups associated for user, using groupProvider.
Post this validation, it will provision user, groups and then create relationship between user and groups.

Sample frontend jaas.conf

WHZ-Authentication {
security.PropertyFileLoginModule sufficient
debug="true"
file="user.props";

com.sun.security.auth.module.LdapLoginModule sufficient
userProvider={}
authIdentity="{USERNAME}@Domain"
userFilter="(&(userPrincipalName={USERNAME}@Domain)(objectClass=person))"
groupProvider={}
groupNameAttribute="cn"
java.naming.security.authentication="simple"
debug="true"
useSSL="true";
};

@github-actions github-actions bot added product PR or Issue related to the DataHub UI/UX community-contribution PR or Issue raised by member(s) of DataHub Community labels Oct 3, 2025
@datahub-cyborg datahub-cyborg bot added the needs-review Label for PRs that need review from a maintainer. label Oct 3, 2025
Copy link

codecov bot commented Oct 3, 2025

Bundle Report

Changes will decrease total bundle size by 81 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
datahub-react-web-esm 28.58MB -81 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: datahub-react-web-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/index-*.js -81 bytes 18.92MB -0.0%

@aabharti-visa
Copy link
Contributor Author

/build

@aabharti-visa
Copy link
Contributor Author

/build pr

@deepgarg760
Copy link
Collaborator

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Oct 6, 2025
@aabharti-visa aabharti-visa force-pushed the feat(frontend)_fetch_groups_ldap_authentication branch from b975849 to 5233d38 Compare October 6, 2025 06:16
@aabharti-visa aabharti-visa force-pushed the feat(frontend)_fetch_groups_ldap_authentication branch from 5233d38 to f7bd56a Compare October 6, 2025 06:51
@aabharti-visa
Copy link
Contributor Author

one test failing: https://github.com/datahub-project/datahub/actions/runs/18217782387/job/51870802886?pr=14918

Hi @deepgarg760 the test case is not related to new test cases which are done in AuthenticationManagerTest but from

ApplicationTest STANDARD_OUT
2025-10-06 07:10:16,107 [application-akka.actor.default-dispatcher-6] INFO controllers.SsoCallbackController - Home URL: /
2025-10-06 07:10:16,332 [application-akka.actor.default-dispatcher-9] INFO filters.BasePathRedirectFilter - BasePathRedirectFilter: Base path configured as: '/'
2025-10-06 07:10:16,655 [Test worker] INFO app.ApplicationTest - Shutdown Mock GMS
2025-10-06 07:10:16,664 [Test worker] INFO app.ApplicationTest - Shutdown Play Frontend
2025-10-06 07:10:16,677 [Test worker] INFO p.a.i.l.c.CoordinatedShutdownSupport - Starting synchronous coordinated shutdown with ServerStoppedReason reason and 2147508000 milliseconds timeout
2025-10-06 07:10:16,694 [application-akka.actor.default-dispatcher-6] INFO akka.actor.CoordinatedShutdown - Running CoordinatedShutdown with reason [ServerStoppedReason]
2025-10-06 07:10:16,719 [application-akka.actor.internal-dispatcher-5] INFO play.core.server.AkkaHttpServer - Terminating server binding for /[0:0:0:0:0:0:0:0]:19001
2025-10-06 07:10:16,802 [application-akka.actor.internal-dispatcher-3] INFO play.core.server.AkkaHttpServer - Running provided shutdown stop hooks
2025-10-06 07:10:16,885 [Test worker] INFO app.ApplicationTest - Shutdown MockOAuth2Server
2025-10-06 07:10:16,887 [Test worker] INFO app.ApplicationTest - Shutdown MockOAuth2Server thread
app.ApplicationTest ✘ initializationError

org.awaitility.core.ConditionTimeoutException: Condition with app.ApplicationTest was not fulfilled within 10 seconds.
    at app//app.ApplicationTest.init(ApplicationTest.java:200)
Caused by: java.util.concurrent.TimeoutException
    at app.ApplicationTest.init(ApplicationTest.java:200)

@datahub-cyborg datahub-cyborg bot added needs-review Label for PRs that need review from a maintainer. and removed pending-submitter-response Issue/request has been reviewed but requires a response from the submitter labels Oct 6, 2025
@deepgarg760 deepgarg760 requested a review from chakru-r October 6, 2025 09:41
Copy link

codecov bot commented Oct 6, 2025

@datahub-cyborg datahub-cyborg bot added pending-submitter-response Issue/request has been reviewed but requires a response from the submitter and removed needs-review Label for PRs that need review from a maintainer. labels Oct 7, 2025
public static Hashtable<String, Object> createLdapEnvironment(
@Nonnull Map<String, String> options, @Nonnull String username, @Nonnull String password) {

Hashtable<String, Object> env = new Hashtable<>();
Copy link
Collaborator

@deepgarg760 deepgarg760 Oct 7, 2025

Choose a reason for hiding this comment

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

any specific reason using hashTable instead of hashmap ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

public static DirContext createLdapContext(Hashtable<String, Object> env) throws NamingException {
return new InitialDirContext(env);
}

Java's LDAP API (InitialDirContext) requires a Hashtable for environment properties hence used it instead of hashMap.

@aabharti-visa aabharti-visa force-pushed the feat(frontend)_fetch_groups_ldap_authentication branch from fdc6934 to 6a4cd05 Compare October 7, 2025 12:06
@aabharti-visa aabharti-visa force-pushed the feat(frontend)_fetch_groups_ldap_authentication branch from 6a4cd05 to a5d7bb8 Compare October 7, 2025 12:08
@Test
public void testCreateLdapEnvironmentWithBasicOptions() {
String username = "testuser";
String password = "testpass";
Copy link

@aikido-pr-checks aikido-pr-checks bot Oct 7, 2025

Choose a reason for hiding this comment

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

Exposed secret in datahub-frontend/test/auth/ldap/LdapConnectionUtilTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security


testUserDN = "CN=TestUser,OU=Users,DC=example,DC=com";
testUsername = "testuser";
testPassword = "testpass";
Copy link

@aikido-pr-checks aikido-pr-checks bot Oct 7, 2025

Choose a reason for hiding this comment

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

Exposed secret in datahub-frontend/test/auth/ldap/LdapUserAttributeExtractorTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security

new LdapProvisioningLogic(mockSystemEntityClient, mockSystemOperationContext);

testUsername = "testuser";
testPassword = "testpass";
Copy link

@aikido-pr-checks aikido-pr-checks bot Oct 7, 2025

Choose a reason for hiding this comment

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

Exposed secret in datahub-frontend/test/auth/ldap/LdapProvisioningLogicTest.java - low severity
Identified a HashiCorp Terraform password field, risking unauthorized infrastructure configuration and security breaches.
View details in Aikido Security

@david-leifker
Copy link
Collaborator

david-leifker commented Oct 7, 2025

I would expect similar configuration options for enabling group provisioning and extraction. Something like this to match the OIDC versions: AUTH_LDAP_JIT_PROVISIONING_ENABLED and AUTH_LDAP_EXTRACT_GROUPS_ENABLED (maybe take a look at the other ones to see if any apply)

@david-leifker
Copy link
Collaborator

We should also update the documentation around ldap+jaas, maybe adding to this document.

@chakru-r
Copy link
Collaborator

chakru-r commented Oct 8, 2025

The changes in AuthenticationManager.java are too LDAP specific which do not make sense when the specific configuration with LDAP you used for testing this is not being used.

This may be better addressed if you reorganise the code into wrapper Custom LoginModule that delegates calls to an LDAPLoginModule and additionally did the group lookup and provision groups/user membership if needed.
With that approach, custom LoginModule would get used only when it is explicitly configured to be used.

The LoginModule can receive some additional object references required to create groups/user membership by calling [Configuration.setConfiguration]((https://docs.oracle.com/javase/8/docs/api/javax/security/auth/login/Configuration.html#setConfiguration-javax.security.auth.login.Configuration-) and adding SystemEntityClient and OperationContext there will give the login module access to these objects and be able to create groups from custom login module.

The custom login module can access these merged configuration options by implementing the initialize method, the last param options contains the config options from jaas.conf and the additional objects added (SystemEntityClient and OperationContext). Your login module would then roughly do what OidcCallbackLogic to create groups and group membership .

Copy link
Collaborator

@chakru-r chakru-r left a comment

Choose a reason for hiding this comment

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

See the comment on alternate approach that keeps the LDAP groups sync code separate into a module and used only when this custom module is explicitly configured.

@yoonhyejin yoonhyejin added hacktoberfest-accepted Acceptance for hacktoberfest https://hacktoberfest.com/participation/ hacktoberfest Targeted Issues & PRs for Hacktoberfest labels Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution PR or Issue raised by member(s) of DataHub Community hacktoberfest Targeted Issues & PRs for Hacktoberfest hacktoberfest-accepted Acceptance for hacktoberfest https://hacktoberfest.com/participation/ pending-submitter-response Issue/request has been reviewed but requires a response from the submitter product PR or Issue related to the DataHub UI/UX

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants