[Affelio-cvs 854] CVS update: affelio/bin

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 12月 16日 (金) 18:04:31 JST


Index: affelio/bin/get_content.cgi
diff -u affelio/bin/get_content.cgi:1.23 affelio/bin/get_content.cgi:1.24
--- affelio/bin/get_content.cgi:1.23	Thu Oct 27 20:15:01 2005
+++ affelio/bin/get_content.cgi	Fri Dec 16 18:04:31 2005
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-# $Id: get_content.cgi,v 1.23 2005/10/27 11:15:01 slash5234 Exp $
+# $Id: get_content.cgi,v 1.24 2005/12/16 09:04:31 slash5234 Exp $
 
 use strict;
 
@@ -26,7 +26,7 @@
 use CGI qw(-unique_headers);
 $CGI::DISABLE_UPLOADS = 1;
 $CGI::POST_MAX = 102_400;
-use CGI::Session qw(-ip_match);
+use CGI::Session; #qw(-ip_match);
 use HTML::Template;
 use Error qw(:try);
 
Index: affelio/bin/loginexec.cgi
diff -u affelio/bin/loginexec.cgi:1.7 affelio/bin/loginexec.cgi:1.8
--- affelio/bin/loginexec.cgi:1.7	Tue Nov  1 13:03:57 2005
+++ affelio/bin/loginexec.cgi	Fri Dec 16 18:04:31 2005
@@ -16,15 +16,13 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# $Id: loginexec.cgi,v 1.7 2005/11/01 04:03:57 slash5234 Exp $
+# $Id: loginexec.cgi,v 1.8 2005/12/16 09:04:31 slash5234 Exp $
 
 use strict;
 
 use lib("../extlib");
 use CGI qw(-unique_headers);
-$CGI::DISABLE_UPLOADS = 1;
-$CGI::POST_MAX = 102_400;
-use CGI::Session qw(-ip_match);
+use CGI::Session;
 use HTML::Template;
 use Error qw(:try);
 
@@ -46,7 +44,8 @@
 my $cfg_dir = "../config/";
 my $af;
 try{
-    $af = new Affelio(ConfigDir => $cfg_dir);
+    $af = new Affelio(ConfigDir => $cfg_dir,
+		      CGI => $q);
 }catch Error with{
     my $e = shift;
     error($q, "Affelio load error.\n" . $e);
@@ -54,83 +53,159 @@
 my $wi = new Affelio::misc::WebInput;
 
 ############################################################################
-#Authentication check
+#Prep
 ############################################################################
+#input data
+my $mode = $wi->PTN_mode($q->url_param("mode"));
+my $affelio_url = $wi->PTN_through($q->param("affelio_url"));
 my $username = $wi->PTN_word($q->param("username"));
 my $password = $wi->PTN_through($q->param("password"));
-my $forward_URL = $wi->PTN_URL($q->param("forward_URL"));
+my $forward_URL = $wi->PTN_URL($q->url_param("forward_URL"));
 
-debug_print("  username = $username\n");
-debug_print("  password = $password\n");
-debug_print("  $af->{site__password}\n");
-debug_print("  $forward_URL\n");
+#Make farm URL in which this Affelio belongs to.
+my $farm_URL = $af->{site__web_root};
+$farm_URL =~ s|/([A-Za-z0-9\-\_]*)$|/|;
 
-if(  (verify_password($password, $af->{site__password}) > 0) 
-     && ($username eq $af->{site__username})                  ){
-
-    debug_print("loginexec.cgi: AUTH Ok.\n");
-    #login OK
-}else{
-
-    #login failed.
-    debug_print("loginexec.cgi: AUTH NG.\n");
-
-    my $TMPL_FILE 
-	= "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/loginfailed.tmpl";
-    my $tmpl = new HTML::Template( filename => $TMPL_FILE);
-    $tmpl->param(web_root => $af->{site__web_root});
-    $tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
-    print "Content-type: text/html; charset=UTF-8\n\n";
-    print $af->translate_templateL10N($tmpl->output);
-
-    debug_print("loginexec.cgi: exit(1).\n");    
-    exit(1);
-}
+debug_print("\t\tmode       = $mode");
+debug_print("\t\taffelio_url= $affelio_url");
+debug_print("\t\tusername   = $username");
+debug_print("\t\tpassword   = $password");
+debug_print("\t\tforward    = $forward_URL");
+debug_print("\t\tfarm_URL   = $farm_URL");    
 
+#output data
+my $issued_cookie="";
+my $next_url;
 
 ############################################################################
-#Startup session
+#Already logined?
 ############################################################################
-my $ss = new CGI::Session("driver:File", 
-			  undef, 
-			  {Directory=> $af->{site__session_dir}});
-
-#Set values into session
-$ss->param("user_afid", $af->{site__web_root});
-$ss->param("user_nickname", $af->{user__nickname});
-$ss->param("type", "self");
-#current time
-#expire time
+if($af->getSM->get_userclass() eq "self"){
+    #Yes, the user is already logged in as the owner.
+
+}else{
+    #No, this user has to be authenticated.
 
-$ss->expire('+7d');
+    if($mode eq ""){
+	###################################################################
+	#OLD protocol (V1)
+	if(  (verify_password($password, $af->{site__password}) > 0) 
+	     && ($username eq $af->{site__username}) ){
+	    debug_print("loginexec.cgi: AUTH Ok.\n");
+	    #login OK
+	}else{
+	    #login failed.
+	    debug_print("loginexec.cgi: AUTH NG.\n");
+	    
+	    my $TMPL_FILE = "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/loginfailed.tmpl";
+	    my $tmpl = new HTML::Template( filename => $TMPL_FILE);
+	    $tmpl->param("forward_URL" => $af->{site__web_root});
+	    $tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
+	    print "Content-type: text/html; charset=UTF-8\n\n";
+	    print $af->translate_templateL10N($tmpl->output);
+	    
+	    debug_print("loginexec.cgi: exit(1).\n");    
+	    exit(1);
+	}    
+    
+    }elsif($mode eq "s0"){
+	####################################################################
+	#Phase S0 (V2 protocol)
+	
+	##################################
+	#Format adjustment of AffelioURL
+	##################################
+	$affelio_url =~ s|/$||;    #remove / at the end of line
+	if($affelio_url !~ /^(http:\/\/)/){
+	    $affelio_url = "http://" . $affelio_url;
+	}
+	
+	##################################
+	#Determine forward_URL
+	##################################
+	#Forward_URL is a URL to which the user will be forwarded after auth.
+	if($forward_URL eq ""){
+	    $forward_URL= $ENV{HTTP_REFERER};
+	}
+	
+	##################################
+	#Go to "s1" phase...
+	##################################
+	my $next_URL
+	    = "$affelio_url/bin/loginexec.cgi?mode=s1&forward_URL=$forward_URL";
+	debug_print("\t\tnext_URL= $next_URL");
+	debug_print("loginexec.cgi($mode): end.");
+	print $q->redirect( -url => $next_URL);
+	exit(1);
+	
+    }elsif($mode eq "s1"){
+	####################################################################
+	#Phase S1 (V2 protocol)
+	#(password input phase)
+	
+	my $TMPL_FILE = "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/login_s1.tmpl";
+	my $tmpl = new HTML::Template( filename => $TMPL_FILE,
+				       die_on_bad_params => 0);
+	$tmpl->param("owner_nickname" => $af->{user__nickname});
+	$tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
+	$tmpl->param("cgi_path" => "$af->{site__web_root}/bin/loginexec.cgi?mode=s2&forward_URL=$forward_URL");
+	print "Content-type: text/html; charset=UTF-8\n\n";
+	print $af->translate_templateL10N($tmpl->output);
+	
+	debug_print("loginexec.cgi($mode): end.");
+	exit(1);
+	
+    }elsif($mode eq "s2"){ 
+	#####################################################################
+	#Phase S2 (V2 protocol)
+	#(auth check phase)
+	if(  (verify_password($password, $af->{site__password}) > 0) ){
+	    debug_print("loginexec.cgi: AUTH Ok.\n");
+	}else{
+	    #login failed.
+	    debug_print("loginexec.cgi: AUTH NG.\n");
+	    
+	    my $TMPL_FILE = "$af->{site__fs_root}/templates/$af->{site__template}/owner_side/loginfailed.tmpl";
+	    my $tmpl = new HTML::Template( filename => $TMPL_FILE);
+	    $tmpl->param("tmpl_path" => "$af->{site__web_root}/templates/$af->{site__template}");
+	    $tmpl->param("forward_URL" => $forward_URL);
+	    print "Content-type: text/html; charset=UTF-8\n\n";
+	    print $af->translate_templateL10N($tmpl->output);
+	    
+	    debug_print("loginexec.cgi: exit(1).\n");    
+	    exit(1);
+	}    
+    }
+    
+    #######################################################################
+    #Startup new session
+    #######################################################################
+    $af->getSM->startup_session(user_afid => $af->{site__web_root},
+				user_nickname => $af->{user_nickname},
+				type => "self");
+    
+    $af->getSM->get_session->expire('+7d');
+    debug_print("loginexec.cgi: startup_session finished.\n");    
 
-debug_print("loginexec.cgi: startup_session finished.\n");    
+    #Prepare a cookie with the session_id
+    $issued_cookie = $af->getSM->issue_cookie();
+}
 
 
 ############################################################################
 #Output
 ############################################################################
 
-#Retrieve a sesion_id
-my $session_id = $ss->id();
-
-#Prepare a cookie with the session_id
-my $cookie = $q->cookie ( -name => "affelio-$af->{user__nickname}",
-                          -value => $session_id,
-                          -path => URL2path($af->{site__web_root}));
-
-debug_print("loginexec.cgi: new cookie [$session_id]\n");
-debug_print("loginexec.cgi: new cookie [" . URL2domain($af->{site__web_root}) .  "]\n");
-debug_print("loginexec.cgi: new cookie [" . URL2path($af->{site__web_root}) .  "]\n");
-
-
-#Print output
 if($forward_URL ne ""){
-    print $q->redirect( -url => $forward_URL,
-			-cookie => $cookie);
+    $next_url= "$af->{site__web_root}/outgoing.cgi?dest_url=$forward_URL"; 
+}else{
+    $next_url= "$af->{site__web_root}/admin.cgi";
+}
+
+if($issued_cookie){
+    print $q->redirect( -url => $next_url, -cookie => $cookie);
 }else{
-    print $q->redirect( -url => "$af->{site__web_root}/admin.cgi",
-			-cookie => $cookie);
+    print $q->redirect( -url => $next_url);
 }
 
 exit(1);
Index: affelio/bin/logoutexec.cgi
diff -u affelio/bin/logoutexec.cgi:1.5 affelio/bin/logoutexec.cgi:1.6
--- affelio/bin/logoutexec.cgi:1.5	Mon Oct 24 17:52:49 2005
+++ affelio/bin/logoutexec.cgi	Fri Dec 16 18:04:31 2005
@@ -16,7 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# $Id: logoutexec.cgi,v 1.5 2005/10/24 08:52:49 slash5234 Exp $
+# $Id: logoutexec.cgi,v 1.6 2005/12/16 09:04:31 slash5234 Exp $
 
 use strict;
 
@@ -24,7 +24,7 @@
 use CGI qw(-unique_headers);
 $CGI::DISABLE_UPLOADS = 1;
 $CGI::POST_MAX = 102_400;
-use CGI::Session qw(-ip_match);
+use CGI::Session; #qw(-ip_match);
 use HTML::Template;
 use Error qw(:try);
 
Index: affelio/bin/recv_mail_ack.cgi
diff -u affelio/bin/recv_mail_ack.cgi:1.9 affelio/bin/recv_mail_ack.cgi:1.10
--- affelio/bin/recv_mail_ack.cgi:1.9	Thu Oct 27 20:15:01 2005
+++ affelio/bin/recv_mail_ack.cgi	Fri Dec 16 18:04:31 2005
@@ -16,14 +16,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
-# $Id: recv_mail_ack.cgi,v 1.9 2005/10/27 11:15:01 slash5234 Exp $
+# $Id: recv_mail_ack.cgi,v 1.10 2005/12/16 09:04:31 slash5234 Exp $
 
 use strict;
 use lib("../extlib");
 use CGI qw(-unique_headers);
 $CGI::DISABLE_UPLOADS = 1;
 $CGI::POST_MAX = 102_400;
-use CGI::Session qw(-ip_match);
+use CGI::Session; #qw(-ip_match);
 use HTML::Template;
 use File::Copy;
 use Math::BigInt;
Index: affelio/bin/send_handshake.cgi
diff -u affelio/bin/send_handshake.cgi:1.5 affelio/bin/send_handshake.cgi:1.6
--- affelio/bin/send_handshake.cgi:1.5	Mon Oct 24 17:52:49 2005
+++ affelio/bin/send_handshake.cgi	Fri Dec 16 18:04:31 2005
@@ -16,14 +16,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #
-# $Id: send_handshake.cgi,v 1.5 2005/10/24 08:52:49 slash5234 Exp $
+# $Id: send_handshake.cgi,v 1.6 2005/12/16 09:04:31 slash5234 Exp $
 
 use strict;
 use lib("../extlib");
 use CGI qw(-unique_headers);
 $CGI::DISABLE_UPLOADS = 1;
 $CGI::POST_MAX = 102_400;
-use CGI::Session qw(-ip_match);
+use CGI::Session; #qw(-ip_match);
 use HTML::Template;
 use Fcntl qw( :DEFAULT :flock);
 use Crypt::DH;


Affelio-cvs メーリングリストの案内
Back to archive index