--- loncom/auth/migrateuser.pm 2005/10/25 19:14:32 1.2 +++ loncom/auth/migrateuser.pm 2018/12/03 23:43:57 1.38 @@ -1,7 +1,7 @@ # The LearningOnline Network # Starts a user off based of an existing token. # -# $Id: migrateuser.pm,v 1.2 2005/10/25 19:14:32 albertel Exp $ +# $Id: migrateuser.pm,v 1.38 2018/12/03 23:43:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -29,62 +29,717 @@ package Apache::migrateuser; use strict; +use LONCAPA qw(:DEFAULT :match); use Apache::Constants qw(:common :http :methods); use Apache::lonauth; use Apache::lonnet; +use Apache::loncommon; +use Apache::lonlocal; +use Apache::lonlogin(); +use Apache::ltiauth; +use Apache::switchserver; +use CGI::Cookie; sub goto_login { - my ($r) = @_; + my ($r,$domain,$data) = @_; + if ((ref($data) eq 'HASH') && ($data->{'lti.login'})) { + &Apache::ltiauth::invalid_request($r,'22'); + } else { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + my $url = '/adm/login'; + if ($domain) { + $url .= '?domain='.$domain; + } + $r->print(&Apache::loncommon::start_page('Going to login',undef, + {'redirect' => [0,$url],}). + '
'.&mt('Transferring to login page.').'
'. + &Apache::loncommon::end_page()); + } + return OK; +} + +sub sso_check { + my ($data) = @_; + my %extra_env; + if (ref($data) eq 'HASH') { + if ($data->{'sso.login'}) { + $extra_env{'request.sso.login'} = $data->{'sso.login'}; + } + if ($data->{'sso.reloginserver'}) { + $extra_env{'request.sso.reloginserver'} = + $data->{'sso.reloginserver'}; + } + if (($data->{'balancer'}) && ($data->{'server'}) && ($data->{'balcookie'})) { + $extra_env{'request.balancercookie'} = $data->{'server'}.':'.$data->{'balcookie'}; + } + } + return \%extra_env; +} + +sub lti_check { + my ($data) = @_; + my %lti_env; + if (ref($data) eq 'HASH') { + if ($data->{'lti.login'}) { + $lti_env{'request.lti.login'} = $data->{'lti.login'}; + if ($data->{'lti.reqcrs'}) { + $lti_env{'request.lti.reqcrs'} = $data->{'lti.reqcrs'}; + } + if ($data->{'lti.reqrole'}) { + $lti_env{'request.lti.reqrole'} = $data->{'lti.reqrole'}; + } + if ($data->{'lti.selfenrollrole'}) { + $lti_env{'request.lti.selfenrollrole'} = $data->{'lti.selfenrollrole'}; + } + if ($data->{'lti.uri'}) { + $lti_env{'request.lti.uri'} = $data->{'lti.uri'}; + } + if ($data->{'lti.target'}) { + $lti_env{'request.lti.target'} = $data->{'lti.target'}; + } + if ($data->{'lti.sourcecrs'}) { + $lti_env{'request.lti.sourcecrs'} = $data->{'lti.sourcecrs'}; + } + } + if ($data->{'lti.passbackid'}) { + $lti_env{'request.lti.passbackid'} = $data->{'lti.passbackid'}; + } + if ($data->{'lti.passbackurl'}) { + $lti_env{'request.lti.passbackurl'} = $data->{'lti.passbackurl'}; + } + if ($data->{'lti.rosterid'}) { + $lti_env{'request.lti.rosterid'} = $data->{'lti.rosterid'}; + } + if ($data->{'lti.rosterurl'}) { + $lti_env{'request.lti.rosterurl'} = $data->{'lti.rosterurl'}; + } + } + return \%lti_env; +} + +sub ip_changed { + my ($r,$udom,$camefrom,$idsref,$dataref) = @_; &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; - $r->print(<- Transferring to login page. - Continue -
- -