2008-12-26 20:18:23 +01:00
|
|
|
##@file
|
|
|
|
# Web form authentication backend file
|
|
|
|
|
|
|
|
##@class
|
|
|
|
# Web form authentication backend class
|
2008-11-24 15:06:54 +01:00
|
|
|
package Lemonldap::NG::Portal::_WebForm;
|
|
|
|
|
|
|
|
use Lemonldap::NG::Portal::Simple qw(:all);
|
|
|
|
use strict;
|
|
|
|
|
2010-01-21 18:38:55 +01:00
|
|
|
our $VERSION = '0.3';
|
2009-06-08 18:29:13 +02:00
|
|
|
|
2009-02-17 15:56:38 +01:00
|
|
|
## @apmethod int authInit()
|
2008-12-26 20:18:23 +01:00
|
|
|
# Does nothing.
|
2008-12-28 09:36:52 +01:00
|
|
|
# @return Lemonldap::NG::Portal constant
|
2008-11-24 15:06:54 +01:00
|
|
|
sub authInit {
|
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
2009-02-17 15:56:38 +01:00
|
|
|
## @apmethod int extractFormInfo()
|
2008-12-26 20:18:23 +01:00
|
|
|
# Read username and password from POST datas
|
2008-12-28 09:36:52 +01:00
|
|
|
# @return Lemonldap::NG::Portal constant
|
2008-11-24 15:06:54 +01:00
|
|
|
sub extractFormInfo {
|
|
|
|
my $self = shift;
|
|
|
|
return PE_FIRSTACCESS
|
2010-01-21 18:38:55 +01:00
|
|
|
unless ( $self->param('user') );
|
2008-11-24 15:06:54 +01:00
|
|
|
return PE_FORMEMPTY
|
2009-06-14 18:43:02 +02:00
|
|
|
unless (
|
2010-03-01 21:32:28 +01:00
|
|
|
( $self->{user} = $self->param('user') )
|
|
|
|
&& ( ( $self->{password} = $self->param('password') )
|
|
|
|
|| ( $self->{newpassword} = $self->param('newpassword') ) )
|
2009-06-14 18:43:02 +02:00
|
|
|
);
|
2009-12-19 09:57:59 +01:00
|
|
|
$self->{oldpassword} = $self->param('oldpassword');
|
|
|
|
$self->{confirmpassword} = $self->param('confirmpassword');
|
|
|
|
$self->{timezone} = $self->param('timezone');
|
|
|
|
$self->{userControl} ||= '^[\w\.\-@]+$';
|
|
|
|
return PE_MALFORMEDUSER unless ( $self->{user} =~ /$self->{userControl}/o );
|
2008-11-24 15:06:54 +01:00
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
2009-02-17 15:56:38 +01:00
|
|
|
## @apmethod int setAuthSessionInfo()
|
2008-12-26 20:18:23 +01:00
|
|
|
# Set password in session datas if wanted.
|
2008-12-28 09:36:52 +01:00
|
|
|
# @return Lemonldap::NG::Portal constant
|
2008-11-24 15:06:54 +01:00
|
|
|
sub setAuthSessionInfo {
|
|
|
|
my $self = shift;
|
|
|
|
|
2010-04-14 17:37:57 +02:00
|
|
|
# authenticationLevel
|
2010-09-01 18:06:01 +02:00
|
|
|
# -1 if password can be remebered
|
|
|
|
# +1 for user/password with HTTPS
|
|
|
|
$self->{_authnLevel} ||= 0;
|
|
|
|
$self->{_authnLevel} += 1 if $self->https();
|
|
|
|
$self->{_authnLevel} -= 1 if $self->{portalAutocomplete};
|
|
|
|
|
|
|
|
$self->{sessionInfo}->{authenticationLevel} = $self->{_authnLevel};
|
2009-04-08 12:32:33 +02:00
|
|
|
|
2009-05-25 14:59:57 +02:00
|
|
|
# Store user submitted login for basic rules
|
|
|
|
$self->{sessionInfo}->{'_user'} = $self->{'user'};
|
|
|
|
|
2008-11-24 15:06:54 +01:00
|
|
|
# Store submitted password if set in configuration
|
|
|
|
# WARNING: it can be a security hole
|
|
|
|
if ( $self->{storePassword} ) {
|
2009-06-14 18:43:02 +02:00
|
|
|
$self->{sessionInfo}->{'_password'} = $self->{'newpassword'}
|
|
|
|
|| $self->{'password'};
|
2008-11-24 15:06:54 +01:00
|
|
|
}
|
2009-06-22 12:01:58 +02:00
|
|
|
|
|
|
|
# Store user timezone
|
|
|
|
$self->{sessionInfo}->{'_timezone'} = $self->{'timezone'};
|
2009-10-12 18:55:35 +02:00
|
|
|
|
2008-11-24 15:06:54 +01:00
|
|
|
PE_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|