feat: add cloudflare turnstile captcha on login #785
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tick the checkbox if you understand [x]:
Description
If a free to use, non-limiting captcha solution is added to the public facing login form, it would provide more security to the application.
I love this project, and i use it on my homelab and private cloud daily. One issue that scratches the back of my mind was there's no captcha in the login form. Forms without these are prone to so many attacks. With this simple widgets, most of the vunerabilities are handled, without the efforts of the dev. So i wanted to try contributing.
I like Cloudflare's Turnstile Captcha solution, it's free to use (without limitation), interchangable with Google's Captcha(as written in its docs). So i spent some time learning Dockge code base, and added this functionality without changing any default behaviour. With this pr, if a user supply Turnstile's site key and secret key(on env), it will be automatically enabled on login form and its backend validation.
Type of change
Change details
In
backend/socket-handlers/main-socket-handler.ts
TURNSTILE_SITE_KEY
In
frontend/src/mixins/socket.ts
In
frontend/src/components/Login.vue
(No-Changes Sent - For Testing) added TURNSTILE_SITE_KEY and TURNSTILE_SECRET_KEY to
npm run dev
, added new script that does local docker build that can be run with thisnpm run build:docker-local
, and test the functionality directly and through docker image(No-Changes Sent - For Testing) added these in the docker compose file, ran
docker compose up
and checked it.Checked the functionality when an invalid credentials are entered, captcha widget resets and does not send old token.
Checklist
(including JSDoc for methods)
Screenshots (if any)