Authen-CAS-UserAgent
view release on metacpan or search on metacpan
lib/Authen/CAS/UserAgent.pm view on Meta::CPAN
396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437=cut
#method that will attach the cas server login handler
# server => the base CAS server uri to add a login handler for
# username => the username to use to login to the specified CAS server
# password => the password to use to login to the specified CAS server
# pgt => the pgt for a proxy login handler
# proxy => a boolean indicating this handler is a proxy login handler
# restful => a boolean indicating if the CAS server supports the RESTful API
# callback => a login callback to use for logging into CAS, it should return a ticket for the specified service
# ticket_heuristics => an array of heuristic callbacks that are performed when searching for the service and ticket in a CAS response
# strict => only allow CAS login when the service is the same as the original url
sub attach_cas_handler($%) {
my $self = shift;
my (%opt) = @_;
#short-circuit if required options aren't specified
return if(!exists $opt{'server'});
return if(!$opt{'proxy'} && !(exists $opt{'username'} && exists $opt{'password'}));
return if($opt{'proxy'} && !$opt{'pgt'});
#sanitize options
$opt{'server'} = URI->new($opt{'server'} . ($opt{'server'} =~ /\/$/o ? '' : '/'))->canonical;
my $callback =
ref($opt{'callback'}) eq 'CODE' ? $opt{'callback'} :
$opt{'proxy'} ? $proxyLoginCallback :
$opt{'restful'} ? $restLoginCallback :
$defaultLoginCallback;
# process any default config values for bundled callbacks/heuristics, we do this here
# instead of in the callbacks to make default values available to custom
# callbacks
$opt{'ticket_heuristics'} = [$opt{'ticket_heuristics'}] if(ref($opt{'ticket_heuristics'}) ne 'ARRAY');
push @{$opt{'ticket_heuristics'}}, $defaultTicketHeuristic;
@{$opt{'ticket_heuristics'}} = grep {ref($_) eq 'CODE'} @{$opt{'ticket_heuristics'}};
$opt{'param_heuristics'} = [$opt{'param_heuristics'}] if(ref($opt{'param_heuristics'}) ne 'ARRAY');
push @{$opt{'param_heuristics'}}, $defaultLoginParamsHeuristic;
@{$opt{'param_heuristics'}} = grep {ref($_) eq 'CODE'} @{$opt{'param_heuristics'}};
#remove any pre-existing login handler for the current CAS server
$self->remove_cas_handlers($opt{'server'});
( run in 0.334 second using v1.01-cache-2.11-cpan-bf8d7bb2d05 )