Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
12.89k stars 1.48k forks source link

Google Recaptcha V2 support #1721

Closed own3mall closed 4 years ago

own3mall commented 5 years ago

Would it be possible to integrate Google's Recaptcha V2 (not a robot) in PeerTube if account registrations are enabled? This would prevent bots from signing up.

As much as I hate to say it (since I hate Google), I've never seen a better working recaptcha in terms of blocking bots.

I think it would be awesome if their recaptcha would show up during using signup.

Booteille commented 5 years ago

Hmm... If we have to add this ReCaptcha thing, I woud love to see it disabled by default and have alternatives available. I am hating so much sites with ReCaptcha that I avoid using them as much as possible.

own3mall commented 5 years ago

I agree, it should be disabled by default. It requires a site key and a private key that you get from Google anyways, so essentially, we'd need a place to put the keys in the admin configuration, and then when a user attempts to register, if it's enabled, we need to load the JS file Google provides to load the recaptcha widget, and then on the registration side, the server needs to make a check with Google to see if it passes.

I've never worked with node.js, but here's a package that makes it easy:

https://www.npmjs.com/package/recaptcha2

I've implemented Recaptcha V2 many times using PHP and jQuery. It's really easy to do, so it should be relatively painless to add and support in PeerTube for someone that is decent with node.js

Jorropo commented 5 years ago

@own3mall I know spam is a problem but, we may don't have to use google. I know what they are doing is very good, but they will may use that to spy and train their AI. But I don't think that the major draw back (and why I think it will probably never been added in peertube). ReCaptcha is an external service. That mean dependence to google, if google decide somethings like "we have enough part of the market, a lot of projects depends of us, its time to make user pay" (wich was probably what happend with maps). Google isn't an angel, this is a company, they must make profit and using recaptcha is accepting to apply google wish (even if that small).

We must at least have to look at https://www.w3.org/WAI/GL/wiki/Captcha_Alternatives_and_thoughts or any link like that. Peertube can't reliable on an external service even for an optional (you may can but it should be able to work at full capacities without external services).

XenonFiber commented 5 years ago

@Jorropo And reCAPTCHA doesn't have functional accessibility options if Google doesn't like your setup. Clicking on their audio challenge has instantly locked me out every single time I've tried, forcing me to do their visual puzzle until it decides to let me through (with anywhere from 1 to 3+ attempts that like to fail regardless of me clicking on everything it says to click on).

Also, the audio challenge isn't accessible to some people either.

own3mall commented 5 years ago

It's not really a dependency. If you have it enabled, PeerTube uses it. If Google quits offering that service, you disable the plugin in your options. No more dependency.

If someone would like to create a Recaptcha service that is better than Google's, feel free. But, it's not easy, so I'd rather just have the option of enabling / disabling Google's Recaptcha. It's not a very hard change to do either... I might do it myself just to get familiar with node.js...

Yes, Google is evil (and alternatives are needed), but unfortunately, some of their products are pretty darn good.

own3mall commented 5 years ago

node.js is complicated, but I'm trying to get this to work:

https://github.com/own3mall/PeerTube/commit/2086bc4167c427491384634c8c98717efb4037f5 https://github.com/own3mall/PeerTube/commit/c65e0554795a08a4d575f97ff01cadbc5837bfef

Asked Choco via email if he can help me out... definitely want to get this to work if possible, and I'd love to learn more about node.js in the process :+1: - not a fan of it so far, but I can see why some would like it...

Jorropo commented 5 years ago

@own3mall :

It's not really a dependency. If you have it enabled, PeerTube uses it. If Google quits offering that service, you disable the plugin in your options. No more dependency.

This is exactly what I'm talking about, yes its for an optional function but its still a dependency, if google shutdown recaptcha we are fucked for this part of peertube.

And we can't just say desactivate captcha, because optional function are maybe optional for you but that doesn't mean they are optional for everyone.

I'll really love to see this functionality but not with google.

Also peertube is made by angular, this is a single big page, so you can't include google's code only where you want it, it will be in every pages also when you don't use this option because the code is static. So why I personally refuse google's recaptcha code but use Angular, because using Angular and ReCapatcha doesn't have the same juridical impact, using ReCaptcha is a backdoor in your website, like google analytics. I personally don't care about be spyed by google (I use google search every day), but that not the case of everyone and imposing this is for me a bad things.

So please if you do that, at least put a message on your instance to warn other people about google intrusion (and load google's code after this message), (that doesn't mean they can't view your video, they can do it but from a free instance).

own3mall commented 5 years ago

Recaptcha would only be used during user signup. After that, it doesn't get used, and no, there is no Google code whatsoever that runs on your site. They do everything in an iframe and load their own JS that stays on their server.

I'm sorry, but you have no clue what you're talking about, and you clearly don't understand how their Recaptcha system works. If Google were to break Recaptcha or change it, it could totally be disabled (in PeerTube's admin options... at least, that's how I'm trying to get it to work), and then that "dependency" (if you can even call it that) would be gone. No breaking functionality whatsoever.

The RecaptchaV2 npm package would only be used if the option is enabled, and all this package does is make a connection to Google's API to get a response that was generated in their initial iframe (where you told Recaptcha to appear - also done using a setting).

I think it would be a nice addition as a toggle-able option that is disabled by default. I think it's only needed in the user signup functionality for now, but it could always be expanded to be a required input when uploading videos. But for now, that's overkill... just need it for user signup.

YouTube would have greatly benefited if they had used their own recaptcha system to prevent bots from uploading the same stupid videos over and over again...

XenonFiber commented 5 years ago

When they "do everything in an iframe and load their own JS" it doesn't stay on their server. It has to be downloaded like any other resource on the internet.

This isn't a good solution. Especially for a software that was made because Google can't run a video sharing site properly.

own3mall commented 5 years ago

You're correct. The end user's browser client downloads the JavaScript, but ultimately, your server is not running any Google code.

Google messed up YouTube, but they can make a good Recaptcha system though. For now, until they mess that up too, but while it's working, I find it quite useful at preventing spam.

ROBERT-MCDOWELL commented 5 years ago

Personally I will never trust google again, to act as big brother is unlawful.

Jorropo commented 5 years ago

@own3mall yes this is usefull, but some free/open alternative exists.

Booteille commented 5 years ago

I hate Google and never want any service powered by Google opt-in as default. I consider it dangerous. (And if you're protecting your privacy, ReCaptcha will not work properly and sometimes it takes more than 5 minutes to solve their puzzles (because they extensively use personnal informations to know if you're an human))

As I said and as Chocobozzz suggested it when he selected labels for this thread, ReCaptcha should be an option through add-on and not a default feature and should definetely be proposed among alternatives.

So. For now, I would suggest to wait until the plugin system is available.

Jorropo commented 5 years ago

@own3mall

If Google were to break Recaptcha or change it, it could totally be disabled (in PeerTube's admin options... at least, that's how I'm trying to get it to work), and then that "dependency" (if you can even call it that) would be gone. No breaking functionality whatsoever.

More precise extrait :

If Google were to break Recaptcha or change it, it could totally be disabled (in PeerTube's admin options...

You are saying you want to implement somethings that works most of the time and add an "addiction" (dependence en français) (I'm forced to use other words because its seems like there is some understanding) to google. Sorry but that havn't place in peertube for me. Peertube is an opensource app, and the for me, if I only take the user part one major advantage of opensource app is they are complete (there is ultra rarely some little missing feature). For big company some things that works most of the time is good enough and they don't see why to make better. But we are not here for money and we can make a near perfect solution not a good enough, recaptcha is good enough but this isn't what an opensource app can pretend to be. Ok peertube is in dev recaptcha will be better than actualy but why not spend that time implementing recaptcha for implementing a good captcha system, without any external server.

and then that "dependency" (if you can even call it that) would be gone. No breaking functionality whatsoever.

If we use recaptcha and then recaptcha gain a price or is gone we will lose captcha, and even if you can run without somethings that works most of the time isn't enough qualitative for peertube.

own3mall commented 5 years ago

Because your scenarios are unlikely to happen. I've been using Recaptcha V2 since it came out, and that was years ago. Solved my forum spam issues, and it works for pretty much everything in terms of fixing that problem.

Jorropo commented 5 years ago

@own3mall everyone was think maps will be free for eternity but that wasn't the case.

Solved my forum spam issues, and it works for pretty much everything in terms of fixing that problem.

Yes I totaly agrea with this BUT that not the unique things to do that, and recaptcha is google, and peertube is an alternative to youtube wich is google. I personaly thinks including google in an alternative to google makes no sense but if it is for you do it. But I agrea with @Booteille and @Chocobozzz, must be in a plugin (or a fork but plugin will makes simpler life to admin).

ROBERT-MCDOWELL commented 5 years ago

you don't need google to protect your website, behind the curtain it's quietly the opposite since they can get ip address, cookies and much more from your website visitors and as someone said above it feeds their A.I more and more, analyzing every behavior, click etc... but Unfortunately this is not a trick unique to recaptcha, plenty of other well know social medias are on it. I made my own captcha in php years ago and never had any bot problems. There are plenty of captcha open source code that you can use locally, without any cross domain request. Example https://www.the-art-of-web.com/php/captcha/ now I guess you can find the same in python, c++ or whatever language

own3mall commented 5 years ago

Those captchas aren't good enough. I've been using my own custom ones as well over the years... see here at the bottom of the login form (as an example):

https://freemeet.me/login.php

Those are not good enough for the AI systems of today. They can easily beat those captchas.

Also, I'm pretty sure that cross origin CORS policies prevent cookies from being shared. All Google can do is set their own cookie (assuming 3rd party cookies are not blocked in the browser), and do their own tracking that way, but actually pulling information from your app... it's not possible... other than possibly obtaining the origin (the domain and page) which isn't a big deal.

own3mall commented 5 years ago

I've got it working in my branch https://github.com/own3mall/PeerTube. There's just a few more tweaks that I want to make.

Here's some screenshots (click to enlarge):

Admin Configuration Page:

Attached Image Hosted by DragNDropz www.dragndropz.com

User Signup Page:

Attached Image Hosted by DragNDropz www.dragndropz.com

Serkan-devel commented 5 years ago

Fine, but please don't merge it to upstream for the sake of keeping the project completely self-contained and FOSS

elevenpassin commented 5 years ago

OMG This is a BIG NO. Please guys, be sane when you suggest features. Including anything that will talk to Google is a mistake. I am fine with having a recaptcha plugin but I would not want it to be turned on by default. That would be an abomination. Instead I suggest we use a FLOSS alternative to Google's reCaptcha as it will further strengthen our freesoftware ecosystem because more people will start using that recaptcha and that would mean that as Peertube is adopted by mainstream society more and more people will contribute to the freesoftware recaptcha. This would further benefit every other free software which relies on it to stop spam.

I think we should have the freesoftware alternative of recaptcha as default spam filter, anyone else not happy with it can install alternative recaptchas (google, yahoo, whatever)

I hope the maintainers of Peertube make sane decisions in this regard. Peertube is freesoftware and let's keep it that way ^^

ROBERT-MCDOWELL commented 5 years ago

FLOSS ecosystem is stupid scam, it's standards created by the corps themselves, at anytime their standards can be rigged and it happened many times since 2000 with web standards.

own3mall commented 5 years ago

Google Recaptcha V2 is in a stable and completed state in my branch (https://github.com/own3mall/PeerTube), and it's turned off by default. Maybe it will help someone else that wants this feature in the future. At least I get to use it myself! :+1:

Serkan-devel commented 5 years ago

Having that poprietary feature there is already tempting, even when disabled by default.

Please keep it FOSS

Serkan-devel commented 5 years ago

Actually, it should be discouraged to even run a peertube instance in that way

Booteille commented 5 years ago

Framasoft, the sponsor behind the project aims to promote FOSS alternatives. They asked people to help them de-google-ify internet. I think we've here a good case where we need to promote an alternative to ReCaptcha.

moritzheiber commented 5 years ago

Aside from the obvious privacy implications there’s also the moral trajectory here of all of your potential users being used to improve Google service (and therefore let them turn a profit) in the end (that’s what they’re using reCAPTCHA for).

This discussion on HN yesterday erupted after changes to reCAPTCHA became apparent (Google uniquely fingerprinting users with the help of reCAPTCHA), maybe its comments can provide a viable alternative?

https://news.ycombinator.com/item?id=20058697

The title of this issue should probably rather be “Implement user verification to deter bots”, with reCAPTCHA just being one solution among many :)

Nutomic commented 5 years ago

I have a different idea to solve this problem. Instead of letting a computer decide if a user is legit, why don't we ask actual humans? Basically, it would work like this: when a new user signs up, they get asked a random question, like "why did you pick this instance", " what kind of videos are you going to upload", or "what topics are you interested in". They should answer this question in 3-5 sentences. Afterwards, Peertube picks some random, active users on the instance to review the text. The " reviewers are voluntary, and they can just ignore this if they don't want to do it. If the majority thinks the user is real, they can sign up. I think this would work really well, as long as the local users ("reviewers") understand that it is in their own interest to keep the instance spam free.

moritzheiber commented 5 years ago

@nutomic I like the idea. Mastodon introduced something similar with 2.8.0 they call „admissions“, where you get put in a queue of potential sign-ups with a few questions asked in the process. Ultimately the moderation team either approves or denies all admissions.

That shouldn’t deter PeerTube to go for a more crowdsourced admission process though :)

Another potential mechanism for discouraging bot behavior or spam would be cooldown periods between posting videos for new(er) users or filesize vs media length checks (whereas if the movie is 2 hours long but basically just a black backdrop with a single written sentence and 30MB large it’s an obvious scam/bot). But that might be a topic for another feature request.

Nutomic commented 5 years ago

Here is a very good article on Recaptcha and possible alternatives, I really recommend that you read it:

https://kevv.net/you-probably-dont-need-recaptcha/

own3mall commented 5 years ago

@Nutomic Still doesn't change my opinion on the matter... those other captchas don't work... I've tried them before and even used my own. Good spam bots are quite capable of breaking through due to decent image recognition. I don't think you've run into a situation where spammers are trying to get through, but I've seen it on many forum platforms I run.

ogmkp commented 5 years ago

You have to find a solution against some BOTS who post lot of content protected vids by API or webhook. The latest automatic blacklist function don't stop them, and moderators gets more work than before.

Thank you.

rigelk commented 4 years ago

With the upcoming 2.1 release, the plugin API will provide hooks that allow captcha plugins to be developed. In fact, the plugin API makes them trivial to develop, and I already put together a recaptcha plugin (and others which will integrate less evil captcha services).

own3mall commented 4 years ago

@rigelk

Great work!

Are there instructions for installing your plugin? Your plugin will work with the 2.1 release? It's not out yet, right?

rigelk commented 4 years ago

Are there instructions for installing your plugin? Your plugin will work with the 2.1 release? It's not out yet, right?

Installing a plugin, from an admin's perspective, can be most easily done via the web admin interface. Setting up the plugin afterwards usually comes down to following the instructions in the "Settings" of the plugin's web interface, or following the eponym section in the README if something more involved is required, which isn't the case of that plugin anyway. Just get your recaptcha API keys and give them to the plugin after its installation, using the web interface.

The 2.1 release will add a parameter to the registration filter which is required by recaptcha, so yes the recaptcha plugin I wrote won't work with previous versions. Release 2.1 is yet to be drafted and neither I nor @Chocobozzz have an ETA atm.

own3mall commented 4 years ago

@rigelk Your plugin works great with PeerTube v2.1.0

Tested it this morning after upgrading. Thanks so much!

own3mall commented 1 year ago

@Chocobozzz The Recaptcha plugin by @rigelk no longer appears to work as of PeerTube 4.3.0. A captcha is no longer displayed during the registration process in my instance of PeerTube 4.3.0. Was something changed that would have broken this plugin? Right now, registration will fail for all new users on my instance.