version 1.2, 2002/08/08 13:45:21
|
version 1.7, 2002/12/04 15:23:39
|
Line 28
|
Line 28
|
|
|
package Apache::lonuploadedacc; |
package Apache::lonuploadedacc; |
|
|
|
# |
|
# The way this is supposed to work: |
|
# |
|
# User A has client machine C |
|
# User A is logged into LON-CAPA server S |
|
# needs file from user B |
|
# homeserver for user B is H |
|
# |
|
# This handler runs on H |
|
# To access a userfile: |
|
# Server S generates a token and puts it into the query string of URL for H |
|
# Client box C asks H for file with token issued by C |
|
# H now must ask S if token is valid, uses S's lond-command tokenauthuserfile |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :remotehost); |
use Apache::Constants qw(:common); |
use Apache::lonnet(); |
use Apache::lonnet(); |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
my $args=$r->args; |
my $args=$r->args; |
&Apache::loncommon::get_unprocessed_cgi($args,['token']); |
&Apache::loncommon::get_unprocessed_cgi($args,['token','tokenissued']); |
my ($dum1,$dum2,$udom,$uname,$ufile)=split(/\//,$r->uri); |
my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri); |
$ufile=~s/^[\~\.]+//; |
$ufile=~s/^[\~\.]+//; |
my ($server)=($ENV{'form.token'}=~/\_([a-zA-Z0-9]+)$/); |
my $remoteserver=$ENV{'form.tokenissued'}; |
|
|
my $reply=&Apache::lonnet::reply('tokenauthuserfile:'. |
my $reply=&Apache::lonnet::reply('tokenauthuserfile:'. |
$udom.'/'.$uname.'/'.$ufile.':'.$ENV{'form.token'}, |
$udom.'/'.$uname.'/'.$ufile.':'.$ENV{'form.token'}, |
$server); |
$remoteserver); |
if ($reply eq 'ok') { |
if ($reply eq 'ok') { |
return OK; |
return OK; |
} else { |
} else { |
&Apache::lonnet::logthis( |
&Apache::lonnet::logthis( |
"Refused userfile access $uname at $udom for $ufile from $server with $ENV{'form.token'}: $reply"); |
"Refused userfile access $uname at $udom for $ufile with $remoteserver token $ENV{'form.token'}: $reply"); |
return FORBIDDEN; |
return FORBIDDEN; |
} |
} |
} |
} |