feat: Add regex support and group names prefix mapping.#55
Open
StephenSantilli wants to merge 7 commits into
Open
feat: Add regex support and group names prefix mapping.#55StephenSantilli wants to merge 7 commits into
StephenSantilli wants to merge 7 commits into
Conversation
…groupNamesPrefix to config.yml.dist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, andgroupNamesOfExternal. 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 relatedin_array_icalls within_array_combined, a helper function which chooses betweenin_array_iorin_array_regexdepending on the config.It uses
@preg_matchand 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 nogroupNamesPrefixis specified, everything will function as normal.This addresses #36.
Misc
bin/console(GitlabCeLdapSync->GitLabCeLdapSync) so the script would runEverything is tested and appears to work, at least in my setup.