use constant COOKIE_SES => 'ses';
use constant COOKIE_LOGGEDIN => 'eg_loggedin';
use constant COOKIE_LOGGEDIN_CAS => 'eg_CAS';
+use constant COOKIE_URL_CAS => 'eg_CAS_URL';
use constant COOKIE_PHYSICAL_LOC => 'eg_physical_loc';
use constant COOKIE_SSS_EXPAND => 'eg_sss_expand';
my $org_unit = $ctx->{physical_loc} || $ctx->{aou_tree}->()->id;
my $persist = $cgi->param('persist');
my $ticket = $cgi->param('ticket');
+ my $cas_redirect_to = $cgi->param('redirect_to');
+ if ($cgi->cookie(COOKIE_URL_CAS)) {
+ $cas_redirect_to = $cgi->cookie(COOKIE_URL_CAS);
+ }
my $cas_flag = '0';
# initial log form only
# values for the other checks
$username = '_CAS_';
$password = '_CAS_';
+
}
+
+ my $login_page = sprintf('%s://%s%s/login',($self->ctx->{is_staff} ? 'oils' : 'https'), $self->ctx->{hostname}, $self->ctx->{opac_root});
+
+ # CAS does not handle complex URLs, so we put the URL in a cookie
+ if (!$cgi->cookie(COOKIE_URL_CAS) && $cas_redirect_to && !$username && !$password) {
+ return $self->generic_redirect(
+ "$login_page?redirect_to=$cas_redirect_to",
+ [
+ # contains the service url for CAS
+ $cgi->cookie(
+ -name => COOKIE_URL_CAS,
+ -path => '/',
+ -secure => 0,
+ -value => $cas_redirect_to,
+ -expires => '+10m'
+ )
+ ]
+ );
+ }
+
return Apache2::Const::OK unless $username and $password;
# Should we append an email hostname to the username?
if ($ticket) {
$args->{ticket} = $ticket;
$cas_flag = '1';
+ } else {
+ # zap CAS redirect if not CAS request
+ $cas_redirect_to = undef;
}
$response = $U->simplereq(
'open-ils.auth_proxy',
my $login_cookie_expires = ($persist) ? CORE::time + $response->{payload}->{authtime} : undef;
return $self->generic_redirect(
+ $cas_redirect_to ||
$cgi->param('redirect_to') || $acct,
[
# contains the actual auth token and should be sent only over https
-value => '1',
-expires => $login_cookie_expires
),
+ # invalidate CAS url since it is only needed at point of authentication
+ # if it is used, have it go to login page
+ $cgi->cookie(
+ -name => COOKIE_URL_CAS,
+ -path => '/',
+ -value => $login_page,
+ -expires => '-1h'
+ ),
# contains only a hint that we are using CAS
$cgi->cookie(
-name => COOKIE_LOGGEDIN_CAS,
my $self = shift;
my $redirect_to = shift || $self->cgi->param('redirect_to');
+ my $login_page = sprintf('%s://%s%s/login',($self->ctx->{is_staff} ? 'oils' : 'https'),
+ $self->ctx->{hostname}, $self->ctx->{opac_root});
+
# If the user was adding anyting to an anonymous cache
# while logged in, go ahead and clear it out.
$self->clear_anon_cache;
-expires => '-1h'
),
$self->cgi->cookie(
+ -name => COOKIE_URL_CAS,
+ -path => '/',
+ -value => $login_page,
+ -expires => '-1h'
+ ),
+ $self->cgi->cookie(
-name => COOKIE_LOGGEDIN_CAS,
-path => '/',
-value => '',