Skip to content

Conversation

@pierre-lehnen-rc
Copy link
Contributor

@pierre-lehnen-rc pierre-lehnen-rc commented Apr 7, 2025

Proposed changes (including videos or screenshots)

This PR adds new settings to configure custom variables that can be created based on data from LDAP attributes, manipulating the data received from LDAP with certain helpers functions, such as string replace, split and match.

For example, with this PR it is possible to receive an attribute from LDAP containing an email address, split that string value by the @ symbol and then use the left side of it as the value for the username field on rocket.chat.

It was done mostly to solve a specific need we were facing, so the only operations supported are the ones we found could be useful at this moment. It can be expanded to support other operations in the future if the need arises.

The operations it currently supports are:

  • string.split
  • string.replace (with or without regex)
  • string.match (using the match result, or using specific values for matched/not-matched)
  • string.substring
  • fallback (use an alternative value if the existing one is invalid, optionally using a min length to determine if the value is valid or not)

Issue(s)

CORE-1070

Steps to test or reproduce

Further comments


This pull request introduces new functionality for handling LDAP custom variables and string manipulation within the Rocket.Chat application. The key changes include:

  1. LDAP Variable Processing:

    • A new utility function processLdapVariables is added to dynamically process and map LDAP entry attributes based on a configuration map.
    • New settings LDAP_DataSync_UseVariables and LDAP_DataSync_VariableMap are introduced to enable and define variable mappings for LDAP data synchronization.
  2. Refactoring and Utility Functions:

    • The LDAPManager class is refactored to improve modularity by extracting several private static helper methods into separate utility functions (getLdapDynamicValue, getLdapString, ldapKeyExists).
    • New utility functions are introduced for various operations, including executeOperation, executeFallback, executeMatch, executeReplace, executeSplit, and executeSubstring, to handle different string manipulations and transformations.
  3. Configuration and Localization:

    • The changeset file documents minor version bumps for related packages and describes the addition of new LDAP settings.
    • New fields for variable handling are added to LDAP connection options.
    • Two new translation keys related to LDAP Data Sync variables are added to the English localization file.

These enhancements aim to provide more flexible and configurable LDAP data processing capabilities, improving the overall functionality and maintainability of the LDAP integration within Rocket.Chat.


This pull request introduces new functionality for handling custom variables and string manipulation within the LDAP data mapper in the Rocket.Chat application. The changes include:

  1. New LDAP Settings: Two new settings, LDAP_DataSync_UseVariables and LDAP_DataSync_VariableMap, have been added to enable and configure variable mappings for LDAP data synchronization.

  2. Utility Functions: Several new utility functions have been introduced to support LDAP operations:

    • getLdapDynamicValue: Retrieves values from an LDAP entry based on a configuration string.
    • getLdapString: Extracts string values from LDAP entries.
    • ldapKeyExists: Checks for the existence of LDAP keys.
    • executeOperation: Centralizes the execution of various string manipulation operations.
    • executeFallback, executeMatch, executeReplace, executeSplit, executeSubstring: Handle specific string operations like fallback values, matching, replacing, splitting, and substring extraction.
  3. Refactoring: The LDAPManager class has been refactored to improve modularity by moving helper methods into separate utility functions.

  4. Process LDAP Variables: A new function, processLdapVariables, has been added to dynamically process and map LDAP entry attributes based on a configuration map.

  5. Localization: Two new translation keys for the LDAP Data Sync variables have been added to the English localization file.

  6. Changeset: A changeset file has been added to describe minor version bumps for related packages and summarize the introduction of new settings for configuring custom variables with string manipulation functions.

These enhancements aim to provide more flexible and powerful LDAP data synchronization capabilities by allowing custom variable configurations and string manipulations.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Apr 7, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Apr 7, 2025

🦋 Changeset detected

Latest commit: ffa345d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 37 packages
Name Type
@rocket.chat/core-typings Minor
@rocket.chat/i18n Minor
@rocket.chat/meteor Minor
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Major
@rocket.chat/gazzodown Major
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/rest-typings Minor
@rocket.chat/ui-contexts Major
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/license Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/mock-providers Patch
@rocket.chat/web-ui-registration Major
@rocket.chat/network-broker Patch
@rocket.chat/models Patch
@rocket.chat/ui-avatar Major
@rocket.chat/ui-client Major
@rocket.chat/ui-video-conf Major
@rocket.chat/ui-voip Major
@rocket.chat/instance-status Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pierre-lehnen-rc pierre-lehnen-rc added this to the 7.6.0 milestone Apr 7, 2025
@pierre-lehnen-rc pierre-lehnen-rc marked this pull request as ready for review April 7, 2025 20:41
@pierre-lehnen-rc pierre-lehnen-rc requested review from a team as code owners April 7, 2025 20:41
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2025

PR Preview Action v1.6.1

🚀 View preview at
https://RocketChat.github.io/Rocket.Chat/pr-preview/pr-35717/

Built to branch gh-pages at 2025-04-17 03:58 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@codecov
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

Attention: Patch coverage is 99.08815% with 3 lines in your changes missing coverage. Please review.

Project coverage is 61.16%. Comparing base (b718fe7) to head (ffa345d).
Report is 85 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #35717      +/-   ##
===========================================
+ Coverage    60.98%   61.16%   +0.18%     
===========================================
  Files         2955     2971      +16     
  Lines        70526    70839     +313     
  Branches     16169    16185      +16     
===========================================
+ Hits         43008    43330     +322     
+ Misses       24570    24560      -10     
- Partials      2948     2949       +1     
Flag Coverage Δ
e2e 57.68% <ø> (-0.02%) ⬇️
unit 75.61% <99.08%> (+0.31%) ⬆️

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

🚀 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.

@pierre-lehnen-rc pierre-lehnen-rc added the stat: QA assured Means it has been tested and approved by a company insider label Apr 11, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Apr 11, 2025
@kodiakhq kodiakhq bot removed the stat: ready to merge PR tested and approved waiting for merge label Apr 11, 2025
@kodiakhq
Copy link
Contributor

kodiakhq bot commented Apr 11, 2025

This PR currently has a merge conflict. Please resolve this and then re-add the ['stat: ready to merge', 'automerge'] label.

Co-authored-by: Marcos Spessatto Defendi <[email protected]>
Co-authored-by: Marcos Spessatto Defendi <[email protected]>
@kody-ai
Copy link

kody-ai bot commented Apr 15, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

1 similar comment
@kody-ai
Copy link

kody-ai bot commented Apr 15, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 15, 2025

Code Review Completed! 🔥

The code review was successfully completed based on your current configurations.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@kody-ai
Copy link

kody-ai bot commented Apr 15, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

1 similar comment
@kody-ai
Copy link

kody-ai bot commented Apr 15, 2025

Kody Review Complete

Great news! 🎉
No issues were found that match your current review configurations.

Keep up the excellent work! 🚀

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Security
Code Style
Kody Rules
Refactoring
Error Handling
Maintainability
Potential Issues
Documentation And Comments
Performance And Optimization
Breaking Changes

Access your configuration settings here.

@pierre-lehnen-rc pierre-lehnen-rc added the stat: ready to merge PR tested and approved waiting for merge label Apr 17, 2025
@kodiakhq kodiakhq bot merged commit 2c19074 into develop Apr 17, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the feat/ldap-variables branch April 17, 2025 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants