view release on metacpan or search on metacpan
Revision history for perl distribution Authen-CAS-External
0.08 2011-10-17
[OTHER]
- Fix POD tests in xt/
0.07 2011-10-17
[ENHANCEMENTS]
- Added support to type TicketGrantingCookie for the format shown in
http://www.ja-sig.org/wiki/display/CASUM/Clustering+CAS.
- Support authenticating with user agents that do not have a cookie jar.
[BUG FIXES]
- Fixed bug where when Authen::CAS::External::UserAgent was destroyed the
user agent that was attached to it would have now-useless handles still
attached.
0.06 2010-04-08
[BUG FIXES]
lib/Authen/CAS/External.pm view on Meta::CPAN
use 5.008001;
use strict;
use utf8;
use warnings 'all';
# Module metadata
our $AUTHORITY = 'cpan:DOUGDUDE';
our $VERSION = '0.08';
use Authen::CAS::External::Library qw(TicketGrantingCookie);
use Moose 0.89;
use MooseX::StrictConstructor 0.08;
use MooseX::Types::Moose qw(Str);
use URI 1.22;
# Clean the imports are the end of scope
use namespace::clean 0.04 -except => [qw(meta)];
# Role
lib/Authen/CAS/External.pm view on Meta::CPAN
has password => (
is => 'rw',
isa => Str,
clearer => 'clear_password',
predicate => 'has_password',
trigger => sub { shift->clear_ticket_granting_cookie },
);
has ticket_granting_cookie => (
is => 'rw',
isa => TicketGrantingCookie,
clearer => 'clear_ticket_granting_cookie',
documentation => q{The Ticket Granting Cookie for the CAS user session},
predicate => 'has_ticket_granting_cookie',
);
has username => (
is => 'rw',
isa => Str,
clearer => 'clear_username',
predicate => 'has_username',
trigger => sub { shift->clear_ticket_granting_cookie },
);
lib/Authen/CAS/External/Library.pm view on Meta::CPAN
use strict;
use utf8;
use warnings 'all';
# Module metadata
our $AUTHORITY = 'cpan:DOUGDUDE';
our $VERSION = '0.08';
use MooseX::Types 0.08 -declare => [qw(
ServiceTicket
TicketGrantingCookie
)];
# Import built-in types
use MooseX::Types::Moose qw(Int Str);
# Clean the imports are the end of scope
use namespace::clean 0.04 -except => [qw(meta)];
# Type definitions
subtype ServiceTicket,
as Str,
where { m{\A ST-.{1,256}}msx };
subtype TicketGrantingCookie,
as Str,
where { m{\A (?:TGC-)? [A-Za-z0-9-]+ (?:-[A-Za-z0-9\.-]+)? \z}msx };
1;
__END__
=head1 NAME
Authen::CAS::External::Library - Types library
lib/Authen/CAS/External/Library.pm view on Meta::CPAN
=head1 METHODS
No methods.
=head1 TYPES PROVIDED
=head2 ServiceTicket
B<Provides no coercions.>
=head2 TicketGrantingCookie
B<Provides no coercions.>
This is the ticket-granting cookie as defined in section 3.6 of the
L<CAS Protocol|http://www.jasig.org/cas/protocol>. This also allows for a domain
name to be present at the end as per discussed in
L<Clustering CAS|http://www.ja-sig.org/wiki/display/CASUM/Clustering+CAS>.
=head1 DEPENDENCIES
lib/Authen/CAS/External/Response.pm view on Meta::CPAN
use 5.008001;
use strict;
use utf8;
use warnings 'all';
# Module metadata
our $AUTHORITY = 'cpan:DOUGDUDE';
our $VERSION = '0.08';
use Authen::CAS::External::Library qw(ServiceTicket TicketGrantingCookie);
use LWP::UserAgent 5.819;
use Moose 0.89;
use MooseX::StrictConstructor 0.08;
use MooseX::Types::Moose qw(Str);
use URI 1.22;
# Clean the imports are the end of scope
use namespace::clean 0.04 -except => [qw(meta)];
# Attributes
lib/Authen/CAS/External/Response.pm view on Meta::CPAN
);
has service_ticket => (
is => 'ro',
isa => ServiceTicket,
clearer => '_clear_service_ticket',
predicate => 'has_service_ticket',
);
has ticket_granting_cookie => (
is => 'ro',
isa => TicketGrantingCookie,
clearer => '_clear_ticket_granting_cookie',
predicate => 'has_ticket_granting_cookie',
);
# Methods
sub get_cookies {
my ($self, @cookie_names) = @_;
lib/Authen/CAS/External/Response.pm view on Meta::CPAN
);
# Make a HEAD request
my $response = $user_agent->head($self->destination);
if (@cookie_names == 0) {
# Return the cookies a a string
return $user_agent->cookie_jar->as_string;
}
# Cookies to return
my %cookies;
# Find the cookies
$user_agent->cookie_jar->scan(sub {
my (undef, $key, $value, undef, $domain) = @_;
if ($domain eq $self->destination->host) {
# Go through each cookie name
foreach my $cookie_name (@cookie_names) {
if ($cookie_name eq $key) {
lib/Authen/CAS/External/Response.pm view on Meta::CPAN
=head2 get_cookies
This method is for convenience purposes. Using this method, a HEAD request
will be made to the destination URL and will return a hash of the cookie
names and their values that would have been set.
B<get_cookies()>
When no arguments are provided, returns a string of the cookies, using the
as_string method of L<HTTP::Cookie|HTTP::Cookie>.
B<get_cookies(@list_of_cookie_names)>
When given a list of cookie names, a hash is returned with only those cookies
where the cookie name is the key and the value is the value.
=head2 has_destination
Returns a Boolean of whether or not the response has an associated
L</destination>.
lib/Authen/CAS/External/UserAgent.pm view on Meta::CPAN
# Redriects are when the login process is completing
return;
}
# Create a location to store the response data
my %response_data;
COOKIE:
{
# Manually extract the cookies into our own jar
my $cookie_jar = HTTP::Cookies->new;
$cookie_jar->extract_cookies($response);
# Gather the ticket granting ticket
$cookie_jar->scan(sub {
my (undef, $key, $value, undef, $domain) = @_;
if ($domain eq $self->cas_url->host && $key eq 'CASTGC') {
# Set the ticket
$response_data{ticket_granting_cookie} = $value;
xt/perlcriticrc view on Meta::CPAN
functions = :builtins
exclude_functions = print
[TestingAndDebugging::RequireUseStrict]
severity = 5
[TestingAndDebugging::RequireUseWarnings]
severity = 5
[Documentation::PodSpelling]
stop_words = CAS login CPAN AnnoCPAN username ServiceTicket TicketGrantingCookie HASHREF perldoc CPAN's UserAgent redirectable