Automate creation of new users from a completely fresh instance, without manual UI access #3290

Open
opened 2026-02-05 06:15:57 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @Benouare on GitHub (Oct 20, 2022).

Describe the feature you'd like

Hi,

I would like to create a user by scripting (CLI or API).
To do this, i would like to do it directly by CLI or to use the API.
The API endpoint is available to create a user, but it needs an token/secret. And to get this, if i am not wrong, i must connect to the web interface and create the token. In this case i would like to create by cli.
I want to do this automaticaly, so i dont want to go in the configuration and click every where. I want to script it.

Describe the benefits this would bring to existing BookStack users

In my case, i want to be able to give an "editor/basic" account and not the admin one. I dont want to allow my users (/client) to have access to the configuration of bookstack, just to have a final/basic account.

Can the goal of this request already be achieved via other means?

Yes.
I can use the API, but i need a token to use it, and to have it, i must connect to the app and generate it manually.
In my case, i want to script everything, so i want to have something like "php artisan bookstack:generate-token --user admin --enddate 12/01/2060..." OR "php artisan bookstack:create-user --name timmy --email timmy@southpark.com --password jimmy --role viewer"

Have you searched for an existing open/closed issue?

  • I have searched for existing issues and none cover my fundemental request

How long have you been using BookStack?

6 months to 1 year

Additional context

Thx for your feedback ;)

Originally created by @Benouare on GitHub (Oct 20, 2022). ### Describe the feature you'd like Hi, I would like to create a user by scripting (CLI or API). To do this, i would like to do it directly by CLI or to use the API. The API endpoint is available to create a user, but it needs an token/secret. And to get this, if i am not wrong, i must connect to the web interface and create the token. In this case i would like to create by cli. I want to do this automaticaly, so i dont want to go in the configuration and click every where. I want to script it. ### Describe the benefits this would bring to existing BookStack users In my case, i want to be able to give an "editor/basic" account and not the admin one. I dont want to allow my users (/client) to have access to the configuration of bookstack, just to have a final/basic account. ### Can the goal of this request already be achieved via other means? Yes. I can use the API, but i need a token to use it, and to have it, i must connect to the app and generate it manually. In my case, i want to script everything, so i want to have something like "php artisan bookstack:generate-token --user admin --enddate 12/01/2060..." OR "php artisan bookstack:create-user --name timmy --email timmy@southpark.com --password jimmy --role viewer" ### Have you searched for an existing open/closed issue? - [X] I have searched for existing issues and none cover my fundemental request ### How long have you been using BookStack? 6 months to 1 year ### Additional context Thx for your feedback ;)
OVERLORD added the 🔨 Feature Request label 2026-02-05 06:15:57 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Oct 20, 2022):

Hi @Benouare,
Could you explain your use-case a bit further?
It sounds like your end goal is to create users automatically, I'm just trying to understand why it's a problem to initially access the system to create setup an account with API access to be able to do that.

@ssddanbrown commented on GitHub (Oct 20, 2022): Hi @Benouare, Could you explain your use-case a bit further? It sounds like your end goal is to create users automatically, I'm just trying to understand why it's a problem to initially access the system to create setup an account with API access to be able to do that.
Author
Owner

@Benouare commented on GitHub (Oct 21, 2022):

Hi @ssddanbrown.
First of all, thx for your reply.

It sounds like your end goal is to create users automatically,

That's exactly my goal, but WITHOUT the web interface (so by CLI or API).

I'm just trying to understand why it's a problem to initially access the system to create setup an account with API access to be able to do that.

Part of the job is already done, as you say it's already possible to create a user with the API.
But, if i am not wrong, to do that you need the Token/Secret of the admin user.
And, if i am not wrong, this token can be generated only by the web interface. So "we" need to connect to the web interface to generate the token/secret before to use it in the api.

In other termes, the issue/problem is that it's not possible to generate the token/secret by commande line ( this doesnt exist php artisan bookstack:generate-token --user admin --enddate 12/01/2060 ) OR a direct commande to create a user (without the api) doesnt exist too (for exemple : php artisan bookstack:create-user --name timmy --email timmy@southpark.com --password jimmy --role viewer)

Hope that it's more clear for you.

@Benouare commented on GitHub (Oct 21, 2022): Hi @ssddanbrown. First of all, thx for your reply. > It sounds like your end goal is to create users automatically, That's exactly my goal, but WITHOUT the web interface (so by CLI or API). > I'm just trying to understand why it's a problem to initially access the system to create setup an account with API access to be able to do that. Part of the job is already done, as you say it's already possible to create a user with the API. But, if i am not wrong, to do that you need the Token/Secret of the admin user. And, if i am not wrong, this token can be generated only by the web interface. So "we" need to connect to the web interface to generate the token/secret before to use it in the api. In other termes, the issue/problem is that it's not possible to generate the token/secret by commande line ( this doesnt exist `php artisan bookstack:generate-token --user admin --enddate 12/01/2060 `) OR a direct commande to create a user (without the api) doesnt exist too (for exemple : `php artisan bookstack:create-user --name timmy --email timmy@southpark.com --password jimmy --role viewer`) Hope that it's more clear for you.
Author
Owner

@ssddanbrown commented on GitHub (Oct 21, 2022):

So "we" need to connect to the web interface to generate the token/secret before to use it in the api.

Sure, Everything you've written is true to my knowledge, and I understand technically what you desire here, but I'm just trying to understand why it's an issue that you'd need to access the interface to perform this step.
Understanding what you're attempting to build here may help me to understand the scenario and think about possible solutions at a wider level.

@ssddanbrown commented on GitHub (Oct 21, 2022): > So "we" need to connect to the web interface to generate the token/secret before to use it in the api. Sure, Everything you've written is true to my knowledge, and I understand technically what you desire here, but I'm just trying to understand why it's an issue that you'd need to access the interface to perform this step. Understanding what you're attempting to build here may help me to understand the scenario and think about possible solutions at a wider level.
Author
Owner

@Benouare commented on GitHub (Oct 21, 2022):

The reason is that I am scripting the bookstack installation and to make this processus i would like to have the token/secret by cli. So "for me" (and just in my case ;) ) it's an "issue" taht i must access to the interface to generate the token/secret.
That's all ;)

I will check if i can do it by my self and make the pr.

@Benouare commented on GitHub (Oct 21, 2022): The reason is that I am scripting the bookstack installation and to make this processus i would like to have the token/secret by cli. So "for me" (and just in my case ;) ) it's an "issue" taht i must access to the interface to generate the token/secret. That's all ;) I will check if i can do it by my self and make the pr.
Author
Owner

@ssddanbrown commented on GitHub (Oct 21, 2022):

Okay, that still doesn't really describe the usage case, just further states you need to automate. I'm going to assume you're building some level of multi-instance sass service, or integrating multiple instance with another sass service.

I will check if i can do it by my self and make the pr.

I would advise not opening a PR, at least without expecting it to be closed unless previously mentioned to be accepted.
I don't want to add new CLI commands to the core app for one-off/limited needs, nor do I want to replicate all admin tasks as API commands.

If it helps, it is possible to register custom commands via the logical theme system.
Our existing create admin command can be found here, which could be tweak to your needs and used via the logical theme system.

@ssddanbrown commented on GitHub (Oct 21, 2022): Okay, that still doesn't really describe the usage case, just further states you need to automate. I'm going to assume you're building some level of multi-instance sass service, or integrating multiple instance with another sass service. > I will check if i can do it by my self and make the pr. I would advise not opening a PR, at least without expecting it to be closed unless previously mentioned to be accepted. I don't want to add new CLI commands to the core app for one-off/limited needs, nor do I want to replicate all admin tasks as API commands. If it helps, it is possible to [register custom commands via the logical theme system](https://github.com/BookStackApp/BookStack/blob/development/dev/docs/logical-theme-system.md#custom-command-registration-example). Our existing create admin command [can be found here](https://github.com/BookStackApp/BookStack/blob/development/app/Console/Commands/CreateAdmin.php), which could be tweak to your needs and used via the logical theme system.
Author
Owner

@Benouare commented on GitHub (Oct 22, 2022):

Hi,
thx again for your reply.

I would like to propose kind of "all in one" server with a static configuration, with for exemple bookstack, homer, nextcloud, some custom apps.
For nextcloud (I think it's a good exemple) i am able, with my installation script, to create kind of "admin" user, that is not the admin of the app. This admin will be able just to create users, but will not be able to add apps / plugins. So thoses actions are totally automatic. At the end of the script, I have nextcloud installed, with letsencrypt, with apache, with maria db, with random passwords for this unique instance.

For bookstack, i would like to do the same : create a admin (it's already done with the cli command) and after that be able to create a "sub admin" that have only the rights to create new users.

@Benouare commented on GitHub (Oct 22, 2022): Hi, thx again for your reply. I would like to propose kind of "all in one" server with a static configuration, with for exemple bookstack, homer, nextcloud, some custom apps. For nextcloud (I think it's a good exemple) i am able, with my installation script, to create kind of "admin" user, that is not the admin of the app. This admin will be able just to create users, but will not be able to add apps / plugins. So thoses actions are totally automatic. At the end of the script, I have nextcloud installed, with letsencrypt, with apache, with maria db, with random passwords for this unique instance. For bookstack, i would like to do the same : create a admin (it's already done with the cli command) and after that be able to create a "sub admin" that have only the rights to create new users.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#3290