Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow arbitrary configID prefixes for user_ldap #45144

Open
ibizaman opened this issue May 2, 2024 · 2 comments
Open

Allow arbitrary configID prefixes for user_ldap #45144

ibizaman opened this issue May 2, 2024 · 2 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap enhancement feature: ldap

Comments

@ibizaman
Copy link

ibizaman commented May 2, 2024

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.

@ibizaman ibizaman added 0. Needs triage Pending check for reproducibility or if it fits our roadmap enhancement labels May 2, 2024
@susnux
Copy link
Contributor

susnux commented May 3, 2024

CC @nextcloud/ldap

@blizzz
Copy link
Member

blizzz commented May 3, 2024

Imo it's fine to extend ldap:create-empty-config to specify a certain prefix in the 's%02d' format. I'd welcome a PR adding this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap enhancement feature: ldap
Projects
None yet
Development

No branches or pull requests

3 participants