Skip to content

feat: Add regex support and group names prefix mapping.#55

Open
StephenSantilli wants to merge 7 commits into
Adambean:masterfrom
StephenSantilli:master
Open

feat: Add regex support and group names prefix mapping.#55
StephenSantilli wants to merge 7 commits into
Adambean:masterfrom
StephenSantilli:master

Conversation

@StephenSantilli
Copy link
Copy Markdown

Hi! This PR resolves the two main issues I had with using this tool for our setup. Feel free to nitpick or let me know if you'd prefer these be accomplished a different way. Neither of the additions should break existing configs or change original behavior if they aren't in use. I'd also like to add nested group support in the future if I have some extra time.

Regex Support

I have added regex support for userNamesToIgnore, groupNamesToIgnore, groupNamesOfAdministrators, and groupNamesOfExternal. There are associated bools for each (e.g. userNamesToIgnoreRegex) to toggle this behavior and checks to make sure this doesn't break existing configs.

I added in_array_regex, which checks if the needle matches any of the regular expressions in haystack. I then replaced the related in_array_i calls with in_array_combined, a helper function which chooses between in_array_i or in_array_regex depending on the config.

It uses @preg_match and roughly follows what you described here in #1. The relevant sections have been added to the README.

Prefix Mapping

I also added a new config item, groupNamesPrefix. This allows for mapping LDAP group names with a defined prefix into GitLab groups without that prefix. It will not create or update membership for groups that don't have the prefix. Checks for group names to ignore, admins, and external still use the original names before removing the prefix and will work for names without the prefix. If no groupNamesPrefix is specified, everything will function as normal.

This addresses #36.

Misc

  • Fixed a couple of typos in the README I caught along the way
  • Fixed the capitalization in bin/console (GitlabCeLdapSync -> GitLabCeLdapSync) so the script would run

Everything is tested and appears to work, at least in my setup.

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.

1 participant