--- loncom/auth/lonwebdavauth.pm 2015/05/29 20:00:49 1.4 +++ loncom/auth/lonwebdavauth.pm 2017/01/30 00:16:31 1.7 @@ -1,7 +1,7 @@ # The LearningOnline Network # Authentication Handler for webDAV access to Authoring Space. # -# $Id: lonwebdavauth.pm,v 1.4 2015/05/29 20:00:49 raeburn Exp $ +# $Id: lonwebdavauth.pm,v 1.7 2017/01/30 00:16:31 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -164,6 +164,13 @@ sub handler { if (&Apache::lonnet::homeserver($uname,$udom) eq $uhome) { &Apache::lonnet::transfer_profile_to_env($sessiondir,$handle); if (&Apache::lonnet::usertools_access($uname,$udom,'webdav')) { + if ($r->user() eq '') { + if ($env{'user.domain'} eq $r->dir_config('lonDefDomain')) { + $r->user($env{'user.name'}); + } else { + $r->user($env{'user.name'}.':'.$env{'user.domain'}); + } + } return OK; } else { return FORBIDDEN; @@ -178,12 +185,18 @@ sub handler { if ($r->user =~ /,/) { ($uname,$udom) = split(/,/,$r->user); + $uname =~ s/^\s+//; + $uname =~ s/\s+$//; + $udom =~ s/^\s+//; + $udom =~ s/\s+$//; unless (($uname =~ /^$match_username$/) && ($udom =~ /^$match_domain$/)) { $r->note_basic_auth_failure; return AUTH_REQUIRED; } } else { $uname = $r->user; + $uname =~ s/^\s+//; + $uname =~ s/\s+$//; ($udom) = ($r->uri =~ m{^/webdav/($match_domain)/}); unless (($udom ne '' ) && ($uname =~ /^$match_username$/) && ($upass ne '')) { $r->note_basic_auth_failure; @@ -285,11 +298,7 @@ sub init_webdav_env { \%userenv,\%domdef,\%is_adv); @env{keys(%disk_env)} = @disk_env{keys(%disk_env)}; untie(%disk_env); - my $ip; - my $c = $r->connection; - if (ref($c)) { - $ip = $c->remote_ip; - } + my $ip = $r->get_remote_host(); &Apache::lonnet::log($udom,$uname,$uhome, "Login webdav/$author $ip"); }