Allow arbitrary configID prefixes for user_ldap
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 36.9k
- Forks
- 5.2k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 713
Description
How to use GitHub
- Please use the 👍 reaction to show that you are interested into the same feature.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Is your feature request related to a problem? Please describe.
When creating a user_ldap config, I cannot choose the configID. This is an issue when automating the configuration of the LDAP app through the CLI.
Indeed, I want to be able to deploy my server with Nextcloud's LDAP app configured through code in an idempotent fashion. The code cannot just call occ ldap:create-empty-config on each deployment.
Describe the solution you'd like
I'd like to be able to call ldap:create-empty-config with a prefix argument and it would create the config with the given prefix or fail if the prefix already exists.
Describe alternatives you've considered
Instead of using the ldap:* CLI tool, I can use the config:app:set user_ldap CLI tool. Indeed, I can create an empty LDAP config with an arbitrary configID with:
occ config:app:set user_ldap s01ldap_configuration_active --value=1
This works but it's not discoverable.
Note also that this way allows to create any prefix, even a non-numerical one, causing havoc when later on you use the CLI tool to generate a new config because of a type-cast to int.
Additional context
Currently, I circumvent this issue with a brittle implementation. To avoid creating a new LDAP config on every deploy, the code enumerates all configIDs and chooses to update a configID whose ldapHost == 127.0.0.1. If no such configID is found, it then calls .
ALL_CONFIG="$(${occ} ldap:show-config --output=json)"
MATCHING_CONFIG_IDs="$(echo "$ALL_CONFIG" | jq '[to_entries[] | select(.value.ldapHost=="127.0.0.1") | .key]')"
if [[ $(echo "$MATCHING_CONFIG_IDs" | jq 'length') > 0 ]]; then
CONFIG_ID="$(echo "$MATCHING_CONFIG_IDs" | jq --raw-output '.[0]')"
else
CONFIG_ID="$(${occ} ldap:create-empty-config --only-print-prefix)"
fi
Btw I'm fine creating a PR for this but wanted first to agree on the general feature and implementation.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the user_ldap CLI entry point for ldap:create-empty-config and the config-prefix handling in apps/user_ldap/lib/Helper.php, especially the referenced lines. Check how ldap:show-config and --only-print-prefix represent IDs. Done means a prefix can be supplied, duplicate prefixes fail, and generated IDs do not break on non-numerical prefixes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100