Commit e414ee51 authored by Xavier Guimard's avatar Xavier Guimard

Prepare captcha (#595)

parent 77e98dd2
......@@ -9,9 +9,7 @@ Build-Depends: debhelper (>= 9),
po-debconf
Build-Depends-Indep: libapache-session-perl,
libauthcas-perl,
libauthen-captcha-perl,
libcache-cache-perl,
libcgi-pm-perl,
libclone-perl,
libconfig-inifiles-perl,
libconvert-pem-perl,
......@@ -22,8 +20,10 @@ Build-Depends-Indep: libapache-session-perl,
libdbd-sqlite3-perl,
libdbi-perl,
libdigest-hmac-perl,
libgd-securityimage-perl,
libglib-perl,
libhtml-template-perl,
libimage-magick-perl,
libio-string-perl,
libjson-perl,
liblasso-perl,
......@@ -290,7 +290,9 @@ Recommends: libnet-facebook-oauth2-perl | libnet-openid-consumer-perl | libnet-o
Suggests: libauthcas-perl,
libauthen-captcha-perl,
libdbi-perl,
libgd-securityimage-perl,
libglib-perl,
libimage-magick-perl,
liblasso-perl,
liblemonldap-ng-handler-perl (= ${binary:Version}),
libnet-facebook-oauth2-perl,
......
......@@ -43,13 +43,11 @@ WriteMakefile(
PREREQ_PM => {
'Apache::Session' => 0,
'Cache::Cache' => 0,
'CGI' => 3.08,
'Crypt::OpenSSL::Bignum' => 0,
'Crypt::OpenSSL::RSA' => 0,
'Crypt::OpenSSL::X509' => 0,
'Crypt::Rijndael' => 0,
'Config::IniFiles' => 0,
'DBI' => 0,
'Digest::SHA' => 0,
'File::Basename' => 0,
'JSON' => 0,
......@@ -57,7 +55,6 @@ WriteMakefile(
'Plack' => 0,
'Net::CIDR::Lite' => 0,
'SOAP::Lite' => 0,
'Storable' => 0,
}, # e.g., Module::Name => 1.1
#EXE_FILES => [ 'scripts/convertConfig', ],
(
......
......@@ -9,27 +9,27 @@ WriteMakefile(
LICENSE => 'gpl',
META_MERGE => {
'recommends' => {
'AuthCAS' => 0,
'DBI' => 0,
'Glib' => 0,
'HTTP::Message' => 0,
'JSON' => 0,
'Lasso' => '2.3.0',
'Lemonldap::NG::Handler' => '1.9.0',
'LWP' => 0,
'LWP::Protocol::https' => 0,
'MIME::Lite' => 0,
'Net::Facebook::Oauth2' => 0,
'Net::OAuth' => 0,
'Net::OpenID::Consumer' => 0,
'Net::OpenID::Server' => 0,
'SOAP::Lite' => 0,
'String::Random' => 0,
'URI' => 0,
'Web::ID' => 0,
'XML::LibXSLT' => 0,
'XML::LibXML' => 0,
'XML::Simple' => 0,
'AuthCAS' => 0,
'DBI' => 0,
'GD::SecurityImage' => 0,
'Glib' => 0,
'HTTP::Message' => 0,
'Image::Magick' => 0,
'Lasso' => '2.3.0',
'LWP' => 0,
'LWP::Protocol::https' => 0,
'MIME::Lite' => 0,
'Net::Facebook::Oauth2' => 0,
'Net::OAuth' => 0,
'Net::OpenID::Consumer' => 0,
'Net::OpenID::Server' => 0,
'SOAP::Lite' => 0,
'String::Random' => 0,
'URI' => 0,
'Web::ID' => 0,
'XML::LibXSLT' => 0,
'XML::LibXML' => 0,
'XML::Simple' => 0,
},
},
BUILD_REQUIRES => {
......@@ -48,14 +48,13 @@ WriteMakefile(
'XML::Simple' => 0,
},
PREREQ_PM => {
'Authen::Captcha' => 0,
'CGI' => 3.08,
'Clone' => 0,
'HTML::Template' => 0,
'Lemonldap::NG::Common' => '1.9.0',
'Net::LDAP' => 0.38,
'Regexp::Assemble' => 0,
'Unicode::String' => 0,
'Clone' => 0,
'HTML::Template' => 0,
'JSON' => 0,
'Lemonldap::NG::Handler' => '1.9.0',
'Net::LDAP' => 0.38,
'Regexp::Assemble' => 0,
'Unicode::String' => 0,
},
(
$] >= 5.005
......
package Lemonldap::NG::Portal::Lib::Captcha;
use strict;
use GD::SecurityImage use_magick => 1;
use Mouse;
use MIME::Base64;
our $VERSION = '2.0.0';
extends 'Lemonldap::NG::Common::Module';
has width =>
( is => 'rw', default => sub { $_[0]->{conf}->{captchaWidth} || 220 } );
has height =>
( is => 'rw', default => sub { $_[0]->{conf}->{captchaHeight} || 40 } );
has lines =>
( is => 'rw', default => sub { $_[0]->{conf}->{captchaLines} || 5 } );
has scramble =>
( is => 'rw', default => sub { $_[0]->{conf}->{captchaScramble} || 1 } );
has fgColor =>
( is => 'rw', default => sub { $_[0]->{conf}->{captchaFg} || '#403030' } );
has bgColor =>
( is => 'rw', default => sub { $_[0]->{conf}->{captchaBg} || '#FF644B' } );
# Returns secret + a HTML <img> tag with embedded image
sub getCaptcha {
my ($self) = @_;
my $image = GD::SecurityImage->new(
width => $self->width,
heigth => $self->heigth,
lines => $self->lines,
gd_font => 'Giant',
scramble => $self->scramble,
);
$image->random;
$image->create( 'normal', 'default', $self->fgColor, $self->bgColor );
my ( $imageData, $mimeType, $rdm ) = $image->out( force => 'png' );
my $img = '<img src="data:image/png;base64,'
. encode_base64( $imageData, '' ) . '">';
return ( $rdm, $img );
}
1;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment