Commit 433401d5 authored by Eric German's avatar Eric German

completion of initial depot

parent d59e8505
......@@ -7,101 +7,99 @@ use MIME::Base64;
use Apache::Session::Memorycached;
use CGI::Carp 'fatalsToBrowser';
use Data::Dumper;
use ReverseProxyConfig; #
use ReverseProxyConfig; #
my $message = '';
#my %param;
my %params = Vars;
my $ligne = Dumper( \%params );
print STDERR "ericgerman $ligne\n";
my $stack_user = Lemonldap::Portal::Standard->new();
my %params =Vars;
my $ligne= Dumper (\%params);
print STDERR "ericgerman $ligne\n";
my $stack_user= Lemonldap::Portal::Standard->new();
my $urlc;
my $urldc;
$retour = $stack_user->process(
param => \%params,
server => $ReverseProxyConfig::ldap_serveur,
port => $ReverseProxyConfig::ldap_port,
DnManager => $ReverseProxyConfig::ldap_admin_dn,
passwordManager => $ReverseProxyConfig::ldap_admin_pd,
branch => $ReverseProxyConfig::ldap_branch_people
);
if ($retour) {
$message = $retour->message;
$erreur = $retour->error;
print STDERR "DEBUG $erreur - \n";
}
my $urldc;
$retour=$stack_user->process(param => \%params,
server => $ReverseProxyConfig::ldap_serveur,
port => $ReverseProxyConfig::ldap_port,
DnManager => $ReverseProxyConfig::ldap_admin_dn,
passwordManager => $ReverseProxyConfig::ldap_admin_pd,
branch => $ReverseProxyConfig::ldap_branch_people
);
if ($retour) {
$message=$retour->message;
$erreur=$retour->error;
print STDERR "DEBUG $erreur - \n";
}
if ($erreur) {
my $ident = $retour->user;
### il n y rien de passee , afficher la grille
my $ident = $retour->user;
### il n y rien de passee , afficher la grille
##------------------------------------------------------------------------------
## Gnration du HTML de la page de formulaire
##------------------------------------------------------------------------------
my $data = {
'urlc' => $urlc,
'urldc' => $urldc,
'message' => $message,
'identifiant' => $ident,
};
my $data = {
'urlc' => $urlc,
'urldc' => $urldc,
'message' => $message,
'identifiant' => $ident,
};
my $template = Template->new($ReverseProxyConfig::template_config);
my $template=Template->new( $ReverseProxyConfig::template_config );
print CGI::header();
print CGI::header();
$template->process( 'login.thtml', $data ) or die( $template->error() );
$template->process( 'login.thtml', $data ) or die($template->error());
##==============================================================================
## Fin du fichier
##==============================================================================
exit;
}
exit;
}
##==============================================================================## Ici tout est ok il faut creer le hash sur la session
##==============================================================================
my $monhash = $retour->infoSession;
my $monhash= $retour->infoSession;
my %session;
tie %session, 'Apache::Session::Memorycached', undef,
{
servers => $ReverseProxyConfig::cache_servers,
local => $ReverseProxyConfig::cache_local,
};
my %session;
tie %session, 'Apache::Session::Memorycached', undef,
{
servers => $ReverseProxyConfig::cache_servers,
local => $ReverseProxyConfig::cache_local,
};
foreach ( keys %{$monhash} ) {
$session{$_} = $monhash->{$_} if $monhash->{$_};
}
foreach (keys %{$monhash}) {
$session{$_}=$monhash->{$_} if $monhash->{$_} ;
}
my $session_id = $session{_session_id};
my $urldc;
my $urldc = $retour->getRedirection;
untie(%session);
my $urldc ;
my $urldc=$retour->getRedirection ;
untie( %session );
##---------------------------------------------------------------------------
## Cration du cookie
##---------------------------------------------------------------------------
my $cookie = CGI::cookie(
-name => $ReverseProxyConfig::cookie_name,
-value => $session_id,
-domain => $ReverseProxyConfig::cookie_domain,
-path => $ReverseProxyConfig::cookie_path,
);
##---------------------------------------------------------------------------
## Gnration du HTML par le template
##---------------------------------------------------------------------------
$urldc = $ReverseProxyConfig::applications_list_URL
if ( $urldc eq '' );
my $data = {
urldc => $urldc,
message => 'Session ' . $session_id . $cookie,
};
my $template = Template->new($ReverseProxyConfig::template_config);
print CGI::header( -Refresh => '1; URL=' . $urldc, -cookie => $cookie );
$template->process( 'redirect.thtml', $data ) or die( $template->error() );
exit(0);
my $cookie = CGI::cookie(
-name => $ReverseProxyConfig::cookie_name,
-value => $session_id,
-domain => $ReverseProxyConfig::cookie_domain,
-path => $ReverseProxyConfig::cookie_path,
);
##---------------------------------------------------------------------------
## Gnration du HTML par le template
##---------------------------------------------------------------------------
$urldc = $ReverseProxyConfig::applications_list_URL
if( $urldc eq '' );
my $data = {
urldc => $urldc,
message => 'Session '.$session_id.$cookie ,
};
my $template=Template->new( $ReverseProxyConfig::template_config );
print CGI::header( -Refresh=>'1; URL='.$urldc, -cookie=>$cookie );
$template->process( 'redirect.thtml', $data ) or die($template->error());
exit( 0 );
......@@ -8,8 +8,7 @@ use MIME::Base64;
use Apache::Session::Memorycached;
use CGI::Carp 'fatalsToBrowser';
use Data::Dumper;
#use ReverseProxyConfig; #
#use ReverseProxyConfig; #
our $template_config;
our $login;
our $applications_list_url;
......@@ -19,123 +18,123 @@ our $domain;
our $ldap_server;
our $ldap_port;
our $ldap_branch_people;
our $pass;
our $pass ;
our $session;
my $message = '';
#my %param;
my %params = Vars;
my $conf = Lemonldap::Config::Parameters->new(
file => "/opt/apache/portail/application_new.xml",
cache => 'CONF'
);
my %params =Vars;
my $conf= Lemonldap::Config::Parameters->new (
file => "/opt/apache/portail/application_new.xml" ,
cache => 'CONF' );
print STDERR "je passe ici $session\n";
my $config = $conf->getDomain('appli.cp');
my $config= $conf->getDomain('appli.cp') ;
print STDERR "je passe ici $session\n";
$template_config = $config->{templates_options};
my $tempopt = 'templates_dir';
my $valeur = $config->{$tempopt};
my $templates_opt =
$conf->formateLineHash( $template_config, $tempopt, $valeur );
$template_config = $templates_opt;
$template_config=$config->{templates_options};
my $tempopt= 'templates_dir';
my $valeur= $config->{$tempopt};
my $templates_opt=$conf->formateLineHash($template_config,$tempopt,$valeur);
$template_config= $templates_opt;
$applications_list_url = $config->{menu};
$login = $config->{login};
$cookie_name = $config->{cookie};
$domain = "." . $config->{name};
$path = $config->{path};
$ldap_server = $config->{ldap_server};
$ldap_port = $config->{ldap_port};
$ldap_branch_people = $config->{ldap_branch_people};
$dnmanager = $config->{DnManager};
$pass = $config->{passwordManager};
my $sessionrr = $conf->findParagraph( 'session', 'memcached' );
$session = $sessionrr->{servers};
my $stack_user = Lemonldap::Portal::Standard->new();
$login= $config->{login};
$cookie_name= $config->{cookie};
$domain= ".".$config->{name};
$path= $config->{path};
$ldap_server= $config->{ldap_server};
$ldap_port= $config->{ldap_port};
$ldap_branch_people=$config->{ldap_branch_people};
$dnmanager= $config->{DnManager} ;
$pass = $config->{passwordManager};
my $sessionrr= $conf->findParagraph('session','memcached');
$session =$sessionrr->{servers} ;
my $stack_user= Lemonldap::Portal::Standard->new();
my $urlc;
my $urldc;
$retour = $stack_user->process(
param => \%params,
server => $ldap_server,
port => $ldap_port,
DnManager => $dnmanager,
passwordManager => $pass,
branch => $ldap_branch_people
);
if ($retour) {
$message = $retour->message;
$erreur = $retour->error;
}
my $urldc;
$retour=$stack_user->process(param => \%params,
server => $ldap_server,
port => $ldap_port,
DnManager => $dnmanager,
passwordManager => $pass,
branch => $ldap_branch_people
);
if ($retour) {
$message=$retour->message;
$erreur=$retour->error;
}
if ($erreur) {
my $ident = $retour->user;
### il n y rien de passee , afficher la grille
my $ident = $retour->user;
### il n y rien de passee , afficher la grille
##------------------------------------------------------------------------------
## Gnration du HTML de la page de formulaire
##------------------------------------------------------------------------------
my $data = {
'urlc' => $urlc,
'urldc' => $urldc,
'message' => $message,
'identifiant' => $ident,
};
my $data = {
'urlc' => $urlc,
'urldc' => $urldc,
'message' => $message,
'identifiant' => $ident,
};
my $template = Template->new($template_config);
my $template=Template->new( $template_config );
print CGI::header();
print CGI::header();
$template->process( 'login.thtml', $data ) or die( $template->error() );
$template->process( 'login.thtml', $data ) or die($template->error());
##==============================================================================
## Fin du fichier
##==============================================================================
exit;
}
exit;
}
##==============================================================================## Ici tout est ok il faut creer le hash sur la session
##==============================================================================
my $monhash = $retour->infoSession;
my $fg = eval $session;
my $monhash= $retour->infoSession;
my $fg = eval $session;
my %session;
tie %session, 'Apache::Session::Memorycached', undef, { 'servers' => $fg };
my %session;
tie %session, 'Apache::Session::Memorycached', undef,
{
'servers' => $fg
};
foreach ( keys %{$monhash} ) {
$session{$_} = $monhash->{$_} if $monhash->{$_};
}
foreach (keys %{$monhash}) {
$session{$_}=$monhash->{$_} if $monhash->{$_} ;
}
my $session_id = $session{_session_id};
my $urldc;
my $urldc = $retour->getRedirection;
untie(%session);
my $urldc ;
my $urldc=$retour->getRedirection ;
untie( %session );
##---------------------------------------------------------------------------
## Cration du cookie
##---------------------------------------------------------------------------
my $cookie = CGI::cookie(
-name => $cookie_name,
-value => $session_id,
-domain => $domain,
-path => $path,
);
print STDERR "ericgerman : session $session_id\n";
##---------------------------------------------------------------------------
## Gnration du HTML par le template
##---------------------------------------------------------------------------
$urldc = $applications_list_url
if ( $urldc eq '' );
my $data = {
urldc => $urldc,
message => 'Session ' . $session_id . $cookie,
};
my $template = Template->new($template_config);
print CGI::header( -Refresh => '1; URL=' . $urldc, -cookie => $cookie );
$template->process( 'redirect.thtml', $data ) or die( $template->error() );
exit(0);
my $cookie = CGI::cookie(
-name => $cookie_name,
-value => $session_id,
-domain => $domain,
-path => $path,
);
print STDERR "ericgerman : session $session_id\n";
##---------------------------------------------------------------------------
## Gnration du HTML par le template
##---------------------------------------------------------------------------
$urldc = $applications_list_url
if( $urldc eq '' );
my $data = {
urldc => $urldc,
message => 'Session '.$session_id.$cookie ,
};
my $template=Template->new( $template_config );
print CGI::header( -Refresh=>'1; URL='.$urldc, -cookie=>$cookie );
$template->process( 'redirect.thtml', $data ) or die($template->error());
exit( 0 );
package Lemonldap::Portal::AccessPolicy;
use strict;
use warnings;
use Net::LDAP::Entry;
use Apache2::Const;
use Data::Dumper;
use Sys::Hostname;
use Lemonldap::Portal::Standard;
our $VERSION = '3.1.0';
sub default {
my $self = shift;
my $Entry=shift;
my $Session=shift ;
my $Org=shift ;
my $Attribute = shift;
my @Profil = $Entry->get_value($Attribute);
foreach my $line (@Profil){
my ($appl,$profile) = split (";",$line);
$Session->{$Org}{lc($appl)} = $profile;
}
}
return 1;
......@@ -3,47 +3,58 @@ use strict;
use warnings;
use Apache2::Const;
use Data::Dumper;
use Template;
use CGI ':cgi-lib';
use Apache2::ServerRec();
our $VERSION = '3.0.0';
sub handler {
my $r = shift;
my $Template = Template->new( 'ABSOLUTE' => 1 );
my $LogoutPage = $r->dir_config('LemonldapLogoutPage');
my $domain = $r->dir_config('LemonldapDomain');
my $cookie = $r->dir_config('LemonldapCookie');
my $Data =
{ 'message' =>
"Votre deconnexion est effective. Veuillez fermer la fenetre" };
print CGI::header();
$Template->process( $LogoutPage, $Data ) or die( $Template->error() );
my $entete = $r->headers_in();
my $Cookies = $entete->{'Cookie'};
# my %input = Vars ;
# my $LogoutPage = $r->dir_config('LemonldapLogoutPage');
# my $domain = $input{'domain'};
# my $cookie = $input{'cookie'};
my $LogoutCookie = CGI::cookie(
-name => $cookie,
-value => '0',
-domain => "." . $domain,
-path => '/',
-expires => 'now'
);
$r->headers_out->add( 'Set-Cookie' => $LogoutCookie );
# my $Data = {'message' => "Votre deconnexion est effective. Veuillez fermer la fenetre"};
# print CGI::header();
# $Template->process( $LogoutPage , $Data ) or die($Template->error());
return Apache2::Const::DONE;
use MIME::Base64;
our $VERSION = '3.1.0';
sub handler {
my $r = shift;
my $domain = $r->dir_config('Domain');
my $cookie = $r->dir_config('Cookie');
my $Portal = $r->dir_config('Portal');
my $PostLogoutURL = $r->dir_config('PostLogoutURL');
my $entete = $r->headers_in();
my $Cookies = $entete->{'Cookie'};
my $LogoutCookie = CGI::cookie(
-name => $cookie,
-value => '0',
-domain => ".".$domain,
-path => '/',
-expires => 'now'
);
my $test = $r->construct_url();
#ATTENTION : ne valide que les http et https
my $prot;
if ($test =~ /^https/){
$prot = "https://";
}else{
$prot = "http://"
}
my $url_portail;
if (defined($PostLogoutURL)){
$url_portail = $PostLogoutURL;
}else{
$url_portail = $prot.$r->headers_in->{Host};
}
my $url_portail_encode = encode_base64($url_portail,"");
$r->err_headers_out->add(Pragma => 'no-cache');
$r->headers_out->add(Location =>$Portal."?op=c&url=$url_portail_encode");
$r->err_headers_out->add(Connection => 'close');
$r->err_headers_out->add( 'Set-Cookie' => $LogoutCookie );
return REDIRECT ;
}
1;
<html>
<head><title>lemonldap websso</title></head>
<body>
<h1>Hello on lemonldap websso 'world</h1>
<form method="post">
<p><p>Fill the 2 fields<p><p>
Enter your user name:(anything) :<input type=text name="identifiant" value="%user%">
<p>$ligne
Enter password:(anything) :<input type=password name="secret" value="%secret%">
<p>
<b>%message%</b>
<p> url demande : %urldc% <p>
<input type=hidden name="url" value="%urldc%">
<input type=submit >
</form>
</body>
</html>
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