Open michacassola opened 1 year ago
I don't use it, as I block request on the network level, but being able to manage plugins through wp-cli is a must have for a good plugin :)
Hi @michacassola, Thanks for your message.
Adding some wp-cli
commands seems indeed a great idea.
But I guess I need more details on the type of command you want available.
Considering the API Key, this is already possible to set it in setting (if you know the API Key):
wp option set crowdsec_api_key ${BOUNCER_KEY}
But if you want a command to create the key itself, I think this won't be possible to have something that will work in all possible cases.
The bouncer key cannot be created with a pure PHP script, as we have to use the CrowdSec CLI cscli
tool.
For example, the bouncer key can be retrieved as the result of the :
cscli bouncers add $BOUNCER_NAME -o raw
And, as the cscli command is only available on the server with the installed CrowdSec agent, it won't be possible to create it if the agent is not on the same server as the WordPress. There could also be some permission issues between the cscli
user and the wp
user.
For now, I guess the easiest way to script the installation of the CrowdSec plugin is to retrieve a bouncer key with the cscli
command and pass it as a parameter of the wp option set
command.
In my opinion, modifying the settings is already possible with the wp option set
command, but we could add some command to manage the cache (clear, refresh, ...)
Please let me know if you were thinking about other wp-cli integration.
Yeah, you are right, if all the options can be passed like that it is sufficient. Then I would like to request documentation on how to set and change all the options of the plugin that way. :) Thanks!
Then I would like to request documentation on how to set and change all the options of the plugin that way. :)
I add this to my TODO list :) . I think I will provide a wp-cli example for each item in this documentation part: https://github.com/crowdsecurity/cs-wordpress-bouncer/blob/main/docs/USER_GUIDE.md#configurations
If you can't wait, you could start by looking in the wp_options
table and search all items with option_name
beginning by crowdsec
.
Thanks
Hi @michacassola,
as a first step in the integration work of WP-CLI, I added a paragraph about How to update settings with WP-CLI.
Next step would be to add some real WP-CLI command to act on the bouncer (clearing, refreshing cache for example).
Thanks
Hi, I'd like to script the installation of the crowdsec plugin. I know of a workaround that could possibly work, but native integration to hand the API key and host details to the plugin and change the settings would be nice!
https://discord.com/channels/921520481163673640/1042925611427057786