Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove captcha #1332

Merged
merged 1 commit into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ requires 'perl', '5.010';
requires 'Archive::Any', '0.0946';
requires 'Archive::Tar', '2.40';
requires 'Authen::SASL', '2.16'; # for Email::Sender::Transport::SMTP
requires 'Captcha::reCAPTCHA', '0.99';
requires 'Catalyst', '5.90128';
requires 'Catalyst::Action::RenderView', '0.16';
requires 'Catalyst::Controller::REST', '1.21';
Expand Down
9 changes: 0 additions & 9 deletions cpanfile.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,6 @@ DISTRIBUTIONS
Canary::Stability 2013
requirements:
ExtUtils::MakeMaker 0
Captcha-reCaptcha-0.99
pathname: S/SU/SUNNYP/Captcha-reCaptcha-0.99.tar.gz
provides:
Captcha::reCAPTCHA 0.99
requirements:
ExtUtils::MakeMaker 0
HTML::Tiny 0.904
LWP::UserAgent 0
Test::More 0
Capture-Tiny-0.48
pathname: D/DA/DAGOLDEN/Capture-Tiny-0.48.tar.gz
provides:
Expand Down
7 changes: 0 additions & 7 deletions es/account/mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@
"type": "string"
}
}
},
"looks_human": {
"type": "boolean"
},
"passed_captcha": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
}
}
}
41 changes: 1 addition & 40 deletions lib/MetaCPAN/Model/User/Account.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,57 +70,18 @@ has access_token => (
handles => { add_access_token => 'push' },
);

=head2 passed_captcha

L<DateTime> when the user passed the captcha.

=cut

has passed_captcha => (
is => 'ro',
isa => 'DateTime',
writer => '_set_passed_captcha',
);

=head2 looks_human

Certain features are disabled unless a user C<looks_human>. This attribute
is true if the user is connected to a PAUSE account or he L</passed_captcha>.

=cut

has looks_human => (
required => 1,
is => 'ro',
isa => ESBool,
lazy => 1,
builder => '_build_looks_human',
clearer => 'clear_looks_human',
);

sub _build_looks_human {
my $self = shift;
return (
( $self->has_identity('pause') || $self->passed_captcha )
? true
: false
);
}

=head1 METHODS

=head2 add_identity

Adds an identity to L</identity>. If the identity is a PAUSE account,
the user ID is added to the corresponding L<MetaCPAN::Document::Author> document
and L</looks_human> is updated.
the user ID is added to the corresponding L<MetaCPAN::Document::Author> document.

=cut

after add_identity => sub {
my ( $self, $identity ) = @_;
if ( $identity->{name} eq 'pause' ) {
$self->clear_looks_human;
my $profile
= $self->index->model->doc('author')->get( $identity->{key} );

Expand Down
3 changes: 1 addition & 2 deletions lib/MetaCPAN/Server/Controller/Login.pm
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ sub update_user {
if ( $c->session->{__user} );
$user ||= $model->new_document;
$user->add_identity( { name => $type, key => $id, extra => $data } );
$user->clear_looks_human; # rebuild
$user->put( { refresh => true } );
$user->put( { refresh => true } );
}
$c->authenticate( { user => $user } );

Expand Down
12 changes: 0 additions & 12 deletions lib/MetaCPAN/Server/Controller/User/Favorite.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,6 @@ use MetaCPAN::Util qw( true false );

BEGIN { extends 'Catalyst::Controller::REST' }

sub auto : Private {
my ( $self, $c ) = @_;
unless ( $c->user->looks_human ) {
$self->status_forbidden( $c,
message => 'please complete the turing test' );
return 0;
}
else {
return 1;
}
}

sub index : Path : ActionClass('REST') {
}

Expand Down
45 changes: 0 additions & 45 deletions lib/MetaCPAN/Server/Controller/User/Turing.pm

This file was deleted.

4 changes: 0 additions & 4 deletions metacpan_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ logger:
filename: ../var/log/metacpan.log
syswrite: 1

controller:
User::Turing:
private_key: 59125ffc09413eed3f2a2c07a37c7a44b95633e2

smtp:
host: smtp.fastmail.com
port: 465
Expand Down
5 changes: 0 additions & 5 deletions metacpan_server_testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ logger:
class: Log::Log4perl::Appender::Screen
name: testing

controller:
User::Turing:
captcha_class: Captcha::Mock
private_key: testing

github_key: foo
github_secret: bar

Expand Down
16 changes: 0 additions & 16 deletions t/server/controller/user/favorite.t
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,6 @@ test_psgi app, sub {

ok( $user = $cb->( GET '/user?access_token=bot' ), 'get bot' );
is( $user->code, 200, 'code 200' );

$user = decode_json_ok($user);
ok( !$user->{looks_human}, 'user looks like a bot' );
ok(
$res = $cb->(
POST '/user/favorite?access_token=bot',
Content => encode_json( {
distribution => 'Moose',
release => 'Moose-1.10',
author => 'DOY'
} )
),
'POST favorite'
);
decode_json_ok($res);
is( $res->code, 403, 'forbidden' );
};

done_testing;
54 changes: 0 additions & 54 deletions t/server/controller/user/turing.t

This file was deleted.

6 changes: 0 additions & 6 deletions t/testrules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ seq:
- seq: t/0*.t

# ensure t/script/cover.t runs before t/server/controller/cover.t

- seq: t/script/cover.t

# If t/server/controller/user/favorite.t this runs too late then the
# looks_human test will fail. We should probably reset the user data, but
# this is a quicker fix for now.

- seq: t/server/controller/user/favorite.t
- par:
- t/**.t