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 $persist = $cgi->param('persist');
# initial log form only
+ 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
+ if ($ticket) {
+ # CAS does not have either username or password at this point, so we fudge these
+ # 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;
my $auth_proxy_enabled = 0; # default false
'open-ils.auth', 'open-ils.auth.authenticate.complete', $args);
} else {
$args->{password} = $password;
+ 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',
'open-ils.auth_proxy.login', $args);
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
-secure => 0,
-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,
+ -path => '/',
+ -secure => 0,
+ -value => $cas_flag,
+ -expires => $login_cookie_expires
)
]
);
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;
-path => '/',
-value => '',
-expires => '-1h'
+ ),
+ $self->cgi->cookie(
+ -name => COOKIE_URL_CAS,
+ -path => '/',
+ -value => $login_page,
+ -expires => '-1h'
+ ),
+ $self->cgi->cookie(
+ -name => COOKIE_LOGGEDIN_CAS,
+ -path => '/',
+ -value => '',
+ -expires => '-1h'
)
]
);