-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Handle auto-creation of API user along Super User #2322
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the PR @Amphaal. API secrets are randomly generated, so it doesn't seem right to pass a manually constructed random looking secret into the DB from the CLI. Doesn't seem semantically right. I do agree that it'd be good to have a way to generate a fully capable API user programmatically. Would be good to know how other apps approach this. Have you seen examples? |
No problem @knadh ! I agree with you, this is kind of an hack to allow "admin" permissions - like we would have pre v4 - which allows me to setup listmonk using automation. What I am used to regarding token usage are:
Regarding current implementation, the first solution seems to fit. Let me know your thoughts about this ! |
Thanks @Amphaal. API tokens are auto-generated strings, so passing a manually constructed string seems off. It then allows for string patterns (including proper words) to be passed as tokens, which technically is fine, but semantically, incorrect. I think a more semantic, but slightly clunky approach is to auto-generate a token (when |
Hi @Amphaal. Would you be able to amend the PR with a |
hi @knadh, sure ! Been under the water the past 2 weeks, but I should be able to push something nice this weekend :) If not, do not hesitate to ping back ! |
Are there any workarounds while this is not implemented? I wrote a little shell script inserting the API user into the DB, but for some reasons auth won't work for him However, if I log in manually as superuser and add another user in the dashboard, the original API user auth magically starts working 😀 The issue is that I need this for integration tests in CI so using dashboard is a bit problematic |
Hi, still under the water, but just a quick heads-up; I used a workaround for my CI / IaC (using Ansible), and it looks like this:
This worked for me in the meantime. |
- During install, listmonk now accepts the env `LISTMONK_ADMIN_API_USER` and creates an API user (with username $LISTMONK_ADMIN_API_USER) with full superadmin permissions. This requires LISTMONK_ADMIN_USER and LISTMONK_ADMIN_API_PASSWORD to be set so that that there's always a superadmin user to avoid bad states, mainly: bot superadmin exists, but no admin user exists, leaving the installation perpetually open with the superadmin user creation UI on the first login. The API user's token is printed to stderr in the following format: `export LISTMONK_ADMIN_API_TOKEN="7I81VSd90UWhKDj5Kq9c6YopToRduyDF"` This can be redirected to a file with ./listmonk 2> /tmp/token or captured directly and then source()'d. - Add new function `core.GetRole(id)`. - Fix `at least one super admin` query in user deletion.
This feature is merged in 562e52c. Please see #2314 (comment) for details. Thank you for kick starting this with the PR @Amphaal! 🎉 |
Many thanks for taking care of this @knadh 👍 |
…knadh#2322. - During install, listmonk now accepts the env `LISTMONK_ADMIN_API_USER` and creates an API user (with username $LISTMONK_ADMIN_API_USER) with full superadmin permissions. This requires LISTMONK_ADMIN_USER and LISTMONK_ADMIN_API_PASSWORD to be set so that that there's always a superadmin user to avoid bad states, mainly: bot superadmin exists, but no admin user exists, leaving the installation perpetually open with the superadmin user creation UI on the first login. The API user's token is printed to stderr in the following format: `export LISTMONK_ADMIN_API_TOKEN="7I81VSd90UWhKDj5Kq9c6YopToRduyDF"` This can be redirected to a file with ./listmonk 2> /tmp/token or captured directly and then source()'d. - Add new function `core.GetRole(id)`. - Fix `at least one super admin` query in user deletion.
…knadh#2322. - During install, listmonk now accepts the env `LISTMONK_ADMIN_API_USER` and creates an API user (with username $LISTMONK_ADMIN_API_USER) with full superadmin permissions. This requires LISTMONK_ADMIN_USER and LISTMONK_ADMIN_API_PASSWORD to be set so that that there's always a superadmin user to avoid bad states, mainly: bot superadmin exists, but no admin user exists, leaving the installation perpetually open with the superadmin user creation UI on the first login. The API user's token is printed to stderr in the following format: `export LISTMONK_ADMIN_API_TOKEN="7I81VSd90UWhKDj5Kq9c6YopToRduyDF"` This can be redirected to a file with ./listmonk 2> /tmp/token or captured directly and then source()'d. - Add new function `core.GetRole(id)`. - Fix `at least one super admin` query in user deletion.
…adh#2314, knadh#2322." This reverts commit bd82a5e.
Would fix #2314