Commit a67d1878 authored by Xavier Guimard's avatar Xavier Guimard

Sympa auto-login feature

parent aa2d4802
......@@ -11,6 +11,7 @@ lib/Lemonldap/NG/Handler/Proxy.pm
lib/Lemonldap/NG/Handler/SharedConf.pm
lib/Lemonldap/NG/Handler/Simple.pm
lib/Lemonldap/NG/Handler/Status.pm
lib/Lemonldap/NG/Handler/SympaAutoLogin.pm
lib/Lemonldap/NG/Handler/Vhost.pm
Makefile.PL
MANIFEST
......
package Lemonldap::NG::Handler::SympaAutoLogin;
use strict;
use Lemonldap::NG::Handler::SharedConf qw(:all);
our @ISA = qw(Lemonldap::NG::Handler::SharedConf);
use Digest::MD5;
open S, '/etc/lemonldap-ng/sympa.secret' or die "Unable to open /etc/lemonldap-ng/sympa.secret";
our $sympaSecret = join('',<S>);
close S;
$sympaSecret =~ s/[\r\n]//g;
sub run {
my $class = shift;
my $r = $_[0];
my $ret = $class->SUPER::run(@_);
# Building Sympa cookie
my $tmp = new Digest::MD5;
$tmp->reset;
$tmp->add($datas->{mail}.$sympaSecret);
my $str = "sympauser=$datas->{mail}:".substr(unpack("H*",$tmp->digest), -8);
# Get cookie header, removing Sympa cookie if exists (avoid security
# problems) and set the new value
$tmp = lmHeaderIn( $r, 'Cookie' );
$tmp =~ s/\bsympauser=[^,;]*[,;]?//;
$tmp .= $tmp ? ";$str" : $str;
lmSetHeaderIn( $r, 'Cookie' => $tmp );
# Return SUPER::run() result
return $ret;
}
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