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

www lon-capa-cvs@mail.lon-capa.org
Sat, 27 Jul 2002 18:48:19 -0000


www		Sat Jul 27 14:48:19 2002 EDT

  Added files:                 
    /loncom/auth	lontokacc.pm 
  Log:
  Bug #481
  Simple token-based access mechanism.
  
  

Index: loncom/auth/lontokacc.pm
+++ loncom/auth/lontokacc.pm
# The LearningOnline Network
# Low security Access Handler for Token-based access 
# (clearance given by other loncapa host)
#
# $Id: lontokacc.pm,v 1.1 2002/07/27 18:48:19 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#

package Apache::lontokacc;

use strict;
use Apache::Constants qw(:common :remotehost);
use Apache::lonnet();
use Apache::loncommon();

sub handler {
    my $r = shift;
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
    ['token','server']);
    if (($ENV{'form.token'}) || ($ENV{'form.server'})) {
        my $tmpinfo=Apache::lonnet::reply('tmpget:'.$ENV{'form.token'},
                                                    $ENV{'form.server'});

        if ($tmpinfo eq $r->uri) {
	   return OK;
        }
    }
    $r->log_reason("Invalid token-based access",$r->filename); 
    return FORBIDDEN;
}

1;
__END__