Move captcha to plugin
Requirements
- [x] Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support or the matrix chat.
- [x] Did you check to see if this issue already exists?
- [x] Is this only a feature request? Do not put multiple feature requests in one issue.
- [x] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
- [x] Do you agree to follow the rules in our Code of Conduct?
Is your proposal related to a problem?
Our current captcha doesnt work well and is unmaintained. It would make sense to remove it and provide plugin hooks for captchas instead. For this the get_captcha endpoint would be changed to return the embed HTML from a plugin hook, and registration endpoint would call another plugin hook to validate the captcha with the remote provider. This would let us support Google captcha, hcaptcha and others without directly integrating their code into Lemmy.
Removing the existing captcha is a breaking change and would have to be done before 1.0. This means removing the captcha_answer table (not necessary anymore) and removing local_site.captcha_enabled and local_site.captcha_difficulty (captcha is enabled automatically if plugin is loaded). The captcha functionality can be disabled temporarily and enabled when the plugin hooks are added.
There is also https://github.com/samirdjelal/captcha-rs , which seems to be pretty similar.
If ppl want to create plugins for different captchas that's up to them, but I don't think we should remove our internal rust-based one. Especially since all the alternatives are almost always self-hosted solutions, or solvers that rely on big tech companies.
I'd rather we fix any issues with our current internal captcha, as that work is already done. I'm sure many instances, especially smaller ones, are using it.
That one doesnt have audio support. But maybe thats better as the current audio captcha is apparently not randomized and is probably easy to decode automatically (https://github.com/daniel-e/captcha/issues/27).
If we add a plugin hook then theres no need to keep the builtin captcha, as captchas would easily be enabled via plugin. It would also be possible to load a captcha plugin by default. And depending on the exact plugin hooks we define, they could also work with the captcha or captcha-rs crates. For example one plugin hook could return the captcha image, and the other validate the response locally. It doesnt necessarily have to rely on a remote service.
In any case having captchas as plugins is better because it allows more people to contribute and develop various solutions. At the moment effectively only the two of us can work to improve captchas and we dont have time for it. With a plugin hook its much easier to create a small project in JS or another language to try a new approach.