# Cockpit Next reCAPTCHA

**URL:** <https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053>\
**Category:** Uncategorized\
**Created:** [October 9, 2019, 1:08pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053 "2019-10-09T13:08:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![9lives](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/9lives/32/581_2.png) [@9lives](https://discourse.getcockpit.com/u/9lives)\
**Post date:** [October 9, 2019, 1:08pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/1 "2019-10-09T13:08:12Z")

</div>

I really need to integrate reCAPTCHA v2 into my Cockpit form (using PHP) because my clients are collecting tons of spam. The unofficial add-on does not work with the latest versions of Cockpit. Can anyone help me with how to validate reCAPTCHA? Front end is easy to integrate but I’m struggling with the server side.

Thanks so much!!

---

<div class="post-metadata">

**Author:** ![it0tt](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/it0tt/32/498_2.png) [@it0tt](https://discourse.getcockpit.com/u/it0tt)\
**Post date:** [April 22, 2020, 10:50am UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/2 "2020-04-22T10:50:53Z")

</div>

Don’t know if you are still looking or have given up but I just came across this (last commit was only 11months ago so am hopefull!): [https://github.com/jimmytricks/Cockpit-with-cURL-and-ReCAPTCHA](https://github.com/jimmytricks/Cockpit-with-cURL-and-ReCAPTCHA)

About to test it and see how it goes… I’ll update this post / add another comment once I know more!

---

<div class="post-metadata">

**Author:** ![it0tt](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/it0tt/32/498_2.png) [@it0tt](https://discourse.getcockpit.com/u/it0tt)\
**Post date:** [April 22, 2020, 12:03pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/3 "2020-04-22T12:03:26Z")

</div>

Nope - can’t figure it out ☹  
Being able to use recaptcha is such a basic necessity… really needs to be built into forms module. I think we just give up and use some other handler

---

<div class="post-metadata">

**Author:** ![9lives](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/9lives/32/581_2.png) [@9lives](https://discourse.getcockpit.com/u/9lives)\
**Post date:** [April 22, 2020, 12:59pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/4 "2020-04-22T12:59:32Z")

</div>

Yeah, I wasn’t able to figure it out then moved on. Thanks for trying and updating this!

---

<div class="post-metadata">

**Author:** ![fafn](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fafn](https://discourse.getcockpit.com/u/fafn)\
**Post date:** [November 29, 2020, 11:54am UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/5 "2020-11-29T11:54:57Z")

</div>

_You probably don’t need it any longer but for anyone coming here from the search or from Google:_

We had the same issues and wrote a small Cockpit Addon ourselves.  
You can get it from [gitlab.com/consulting-group-esslingen/cockpit-addons/cockpit-recaptcha](https://gitlab.com/consulting-group-esslingen/cockpit-addons/cockpit-recaptcha#cockpit-recaptcha)

---

<div class="post-metadata">

**Author:** ![9lives](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/9lives/32/581_2.png) [@9lives](https://discourse.getcockpit.com/u/9lives)\
**Post date:** [November 30, 2020, 7:35pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/6 "2020-11-30T19:35:46Z")

</div>

This is awesome. Thank you!

---

<div class="post-metadata">

**Author:** ![drascom](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/drascom/32/718_2.png) [@drascom](https://discourse.getcockpit.com/u/drascom)\
**Post date:** [June 16, 2021, 5:34pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/7 "2021-06-16T17:34:01Z")

</div>

thank you. it is important to improve cockpit with help of community.  
i didnt quite understant which endpoint i need to send the form.  
is it “/api/forms/submit/recaptcha\_server\_key”  
do you have any example somewhere ?

---

<div class="post-metadata">

**Author:** ![fafn](https://avatars.discourse-cdn.com/v4/letter/f/6de8d8/32.png) [@fafn](https://discourse.getcockpit.com/u/fafn)\
**Post date:** [June 19, 2021, 8:58am UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/8 "2021-06-19T08:58:34Z")

</div>

You can submit your form to the regular endpoint of Cockpit, just include the recaptcha-response with the other data you are sending like so:

```auto
let data = {
    field1: 'value1',
    field2: 'value2',
    'g-recaptcha-response': grecaptcha.getResponse()
};

fetch(`YOUR-COCKPIT-URL/forms/submit/YOUR-FORM-ID?token=YOUR-API-TOKEN`, {
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ form: data })
}).then(entry => entry.json()).then(entry => {
    if (entry.errors || entry.error) {
        console.log(entry);
    } else {
        // SUCCESS
    }
});

```

Also check the Cockpit [Forms Doc here](https://getcockpit.com/documentation/modules/forms) and the [Forms API Doc here](https://getcockpit.com/documentation/api/forms).

---

<div class="post-metadata">

**Author:** ![drascom](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/drascom/32/718_2.png) [@drascom](https://discourse.getcockpit.com/u/drascom)\
**Post date:** [June 22, 2021, 5:04pm UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/9 "2021-06-22T17:04:31Z")

</div>

thank you for explanation. it is working now 🙂

---

<div class="post-metadata">

**Author:** ![irq5](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/irq5/32/1495_2.png) [@irq5](https://discourse.getcockpit.com/u/irq5)\
**Post date:** [December 24, 2024, 3:21am UTC](https://discourse.getcockpit.com/t/cockpit-next-recaptcha/1053/10 "2024-12-24T03:21:28Z")

</div>

now cockpit config use /config/config.php  
but in this addon use .yaml  
how to config. for cockpit last version?
