[LON-CAPA-cvs] cvs: loncom /auth lonacc.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 29 Aug 2006 20:04:41 -0000


albertel		Tue Aug 29 16:04:41 2006 EDT

  Modified files:              
    /loncom/auth	lonacc.pm 
  Log:
  - SSO in works with remote contrl now
  - enable a way to optionally configure a page to direct users to
    if they SSO in and lon-capa doesn't know them
  
  
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.92 loncom/auth/lonacc.pm:1.93
--- loncom/auth/lonacc.pm:1.92	Tue Aug  8 13:20:15 2006
+++ loncom/auth/lonacc.pm	Tue Aug 29 16:04:41 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.92 2006/08/08 17:20:15 albertel Exp $
+# $Id: lonacc.pm,v 1.93 2006/08/29 20:04:41 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -150,24 +150,33 @@
 	$handle=$lonid->value;
         $handle=~s/\W//g;
     }
-      
+
     my ($sso_login);
     if ($r->user 
+	#&& $r->user ne 'lonadm'
 	&& (!$lonid || !-e "$lonidsdir/$handle.id" || $handle eq '') ) {
-	$sso_login = 1;
+	&Apache::lonnet::logthis("$handle and -e ".(-e "$lonidsdir/$handle.id"));
+
 	my $domain = $r->dir_config('lonDefDomain');
 	my $home=&Apache::lonnet::homeserver($r->user,$domain);
-	if ($home !~ /(con_lost|no_such_host)/) {
-	    $handle=&Apache::lonauth::success($r,$r->user,$domain,
-					     $home,'noredirect');
-	    $r->header_out('Set-cookie',"lonID=$handle; path=/");
+	if ($home !~ /(con_lost|no_host|no_such_host)/) {
+	    my %info=('ip'        => $r->connection->remote_ip(),
+		      'domain'    => $domain,
+		      'username'  => $r->user,
+		      'server'    => $r->dir_config('lonHostID'),
+		      'sso.login' => 1
+		      );
+	    my $token = &Apache::lonnet::tmpput(\%info,
+						$r->dir_config('lonHostID'));
+	    $env{'form.token'} = $token;
+	    $r->internal_redirect('/adm/migrateuser');
+	    return OK;
+	} elsif (defined($r->dir_config('lonSSOUserUnkownRedirect'))) {
+	    $r->internal_redirect($r->dir_config('lonSSOUserUnkownRedirect'));
+	    return OK;
 	}
     }
 
-    if ($sso_login) {
-	&Apache::lonnet::appenv('request.sso.login' => 1);
-    }
-
     if ($r->dir_config("lonBalancer") eq 'yes') {
 	$r->set_handlers('PerlResponseHandler'=>
 			 [\&Apache::switchserver::handler]);