Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r19628: LJSUP-9334: New auth system for external...

Committer: amyshkin
LJSUP-9334: New auth system for external domains (livejournal.sg)
U   trunk/cgi-bin/Apache/LiveJournal.pm
U   trunk/cgi-bin/LJ/Session.pm
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- trunk/cgi-bin/Apache/LiveJournal.pm	2011-08-08 07:01:15 UTC (rev 19627)
+++ trunk/cgi-bin/Apache/LiveJournal.pm	2011-08-08 07:19:41 UTC (rev 19628)
@@ -195,21 +195,19 @@
     # try to match controller
     LJ::Mob::Router::match_controller();
 
-    if(my $controller = LJ::Request->notes('controller')) {
+    if ( my $controller = LJ::Request->notes('controller') ) {
         my $url = $controller->check_access(LJ::Request->notes('branding_id'), LJ::get_remote_ip);
-        if(LJ::Request->notes('method') eq '__setdomsess') {
-warn "Demiurg: Apache handler: " . __LINE__;
+        if ( LJ::Request->notes('method') eq '__setdomsess' ) {
             return redir(LJ::Session->setdomsess_handler())
-        } else {
-warn "Demiurg: Apache handler: " . __LINE__;
+        }
+        else {
             my $session = LJ::Session->session_from_cookies(
                 tried_fast   => 0,
                 redirect_ref => \$LJ::CACHE_REMOTE_BOUNCE_URL,
                 ignore_ip    => 1
             );
-warn "Demiurg: Apache handler: " . __LINE__;
-            if( !$session && $LJ::CACHE_REMOTE_BOUNCE_URL ) {
-warn "Demiurg: Apache handler: " . __LINE__;
+
+            if ( !$session && $LJ::CACHE_REMOTE_BOUNCE_URL ) {
                 return redir($LJ::CACHE_REMOTE_BOUNCE_URL);
             }
         }

Modified: trunk/cgi-bin/LJ/Session.pm
===================================================================
--- trunk/cgi-bin/LJ/Session.pm	2011-08-08 07:01:15 UTC (rev 19627)
+++ trunk/cgi-bin/LJ/Session.pm	2011-08-08 07:19:41 UTC (rev 19628)
@@ -378,10 +378,7 @@
 sub valid {
     my $sess = shift;
     my $now = time();
-    my $err = sub {
-        warn "Demiurg: valid: " . Dumper(\@_);
-        0;
-    };
+    my $err = sub { 0; };
 
     return $err->("Invalid auth") if $sess->{'timeexpire'} < $now;
 
@@ -578,31 +575,32 @@
 #  -- frontend to session_from_domain_cookie and session_from_master_cookie below
 sub session_from_cookies {
     my $class = shift;
+
+    # for debug only. keep in secret!
+    my %GET = LJ::Request->args;
+    if ( exists $GET{'655'} && $GET{'655'} eq '125' ) {
+        warn "Incoming headers: " . Dumper(LJ::Request->headers_in());
+    }
+
     my %getopts = @_;
-warn "Demiurg: session_from_cookies";
+
     # must be in web context
     return undef unless LJ::Request->is_inited;
 
     my $sessobj;
     my $host = LJ::Request->header_in("Host");
     my $domain_cookie = LJ::Session->domain_cookie;
-warn "Demiurg: session_from_cookies: host = $host";
+
     # foreign domain case
     unless ( $host =~ /\.$LJ::DOMAIN(:\d+)?$/ ) {
-warn "Demiurg: session_from_cookies: found external domain";
-my $tmp = LJ::Session->session_from_external_cookie(\%getopts, @{ $BML::COOKIE{"$domain_cookie\[\]"} || [] });
-warn "Demiurg: session_from_cookies: session: " . Dumper($tmp);
-        return $tmp;
+        return LJ::Session->session_from_external_cookie(\%getopts, @{ $BML::COOKIE{"$domain_cookie\[\]"} || [] });
     }
-warn "Demiurg: session_from_cookies: no external domain";
+
     if ($domain_cookie) {
-warn "Demiurg: session_from_cookies: found local domain";
         # journal domain
         $sessobj = LJ::Session->session_from_domain_cookie(\%getopts, @{ $BML::COOKIE{"$domain_cookie\[\]"} || [] });
-warn "Demiurg: session_from_cookies: session: " . Dumper($sessobj);
     }
     else {
-warn "Demiurg: session_from_cookies: master domain";
         # this is the master cookie at "www.livejournal.com" or "livejournal.com";
         my @cookies = @{ $BML::COOKIE{'ljmastersession[]'} || [] };
 
@@ -614,7 +612,6 @@
         }
 
         $sessobj = LJ::Session->session_from_master_cookie(\%getopts, @cookies);
-warn "Demiurg: session_from_cookies: session: " . Dumper($sessobj);
     }
 
     return $sessobj;
@@ -626,7 +623,6 @@
 
     my $no_session = sub {
         my $reason = shift;
-warn "Demiurg: session_from_external_cookie: $reason: ";
         my $rr = $opts->{redirect_ref};
 
         if ($rr) {
@@ -648,7 +644,6 @@
     return $no_session->("no cookies") unless @cookies;
 
     my $domcook = LJ::Session->domain_cookie;
-warn "Demiurg: session_from_external_cookie: \$domcook = $domcook";
     foreach my $cookie (@cookies) {
         my $sess = valid_domain_cookie($domcook, $cookie, undef, {ignore_li_cook=>1,});
 
@@ -1048,7 +1043,6 @@
 # session's uid/sessid
 sub valid_domain_cookie {
     my ($domcook, $val, $li_cook, $opts) = @_;
-warn "Demiurg: valid_domain_cookie start: " . Dumper(\@_);
     $opts ||= {};
 
     my ($cookie, $gen) = split m!//!, $val;
@@ -1078,7 +1072,6 @@
 
     my $not_valid = sub {
         my $reason = shift;
-warn "Demiurg: valid_domain_cookie: $reason: " . Dumper(\@_);
         return undef;
     };
 

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-08-08 07:01:15 UTC (rev 19627)
+++ trunk/cgi-bin/LJ/User.pm	2011-08-08 07:19:41 UTC (rev 19628)
@@ -10009,7 +10009,6 @@
     return $LJ::CACHE_REMOTE if $LJ::CACHED_REMOTE && ! $opts->{'ignore_ip'};
 
     my $no_remote = sub {
-warn "Demiurg: get_remote: " . __LINE__ . ": " . shift;
         LJ::User->set_remote(undef);
         return undef;
     };

Tags: livejournal, pm, zilogic
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments