| 1 | package OpenID::Login::Discover; | ||||||||||||||||||||
| 2 | { | ||||||||||||||||||||
| 3 | 4 | $OpenID::Login::Discover::VERSION = '0.1.2'; | |||||||||||||||||||
| 4 | } | ||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | # ABSTRACT: Find an endpoint for generic OpenID identifiers | ||||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 4 | ▶ | use Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 4 | has claimed_id => ( | |||||||||||||||||||
| 11 | is => 'rw', | ||||||||||||||||||||
| 12 | isa => 'Str', | ||||||||||||||||||||
| 13 | required => 1, | ||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 4 | has ua => ( | |||||||||||||||||||
| 17 | is => 'rw', | ||||||||||||||||||||
| 18 | isa => 'LWP::UserAgent', | ||||||||||||||||||||
| 19 | required => 1, | ||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | 5 | ▶ | sub perform_discovery { | ||||||||||||||||||
|
Subroutine
perform_discovery: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||
| 24 | 5 | my $self = shift; | |||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 5 | my $claimed_id = $self->claimed_id; | |||||||||||||||||||
| 27 | 5 | ▶ | my $server = $self->_get_xrds_location($claimed_id) || $self->claimed_id; | ||||||||||||||||||
|
Condition33%1/3
$self->_get_xrds_location($claimed_id) || $self->claimed_id
MC/DC0%0/2
$self->_get_xrds_location($claimed_id) || $self->claimed_id
$self->_get_xrds_location($claimed_id)
$self->claimed_id
Truth table33%1/3
A || B
A= $self->_get_xrds_location($claimed_id)B= $self->claimed_id
| |||||||||||||||||||||
| 28 | 5 | my $open_id_endpoint; | |||||||||||||||||||
| 29 | 5 | ▶ | if ($server) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 5 | my $xrds = $self->_get($server)->decoded_content; | |||||||||||||||||||
| 31 | 5 | ▶ | if ( $xrds =~ m{<URI>([^<>]+)</URI>} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 5 | $open_id_endpoint = $1; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 5 | return $open_id_endpoint; | |||||||||||||||||||
| 37 | } | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 10 | ▶ | sub _get { | ||||||||||||||||||
|
Subroutine
_get: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 40 | 10 | my ( $self, $url ) = @_; | |||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 10 | my $ua = $self->ua; | |||||||||||||||||||
| 43 | 10 | my $res = $ua->get($url); | |||||||||||||||||||
| 44 | 10 | ▶ | $res->is_success or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 10 | $res; | |||||||||||||||||||
| 46 | } | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 5 | ▶ | sub _get_xrds_location { | ||||||||||||||||||
|
Subroutine
_get_xrds_location: called CC=3 SCAR=11.3
| |||||||||||||||||||||
| 49 | 5 | my ( $self, $entry_point ) = @_; | |||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | 5 | my $res = $self->_get( $entry_point, Accept => 'application/xrds+xml' ); | |||||||||||||||||||
| 52 | 5 | ▶ | return unless $res; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 53 | 5 | ▶ | my $xrds_location = $res->header('X-XRDS-Location') or return; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 54 | 5 | return $xrds_location; | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | 4 | ▶ | no Moose; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 58 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||
| 59 | 4 | 1; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | |||||||||||||||||||||
| 63 | =pod | ||||||||||||||||||||
| 64 | |||||||||||||||||||||
| 65 | =head1 NAME | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | OpenID::Login::Discover - Find an endpoint for generic OpenID identifiers | ||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | =head1 VERSION | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | version 0.1.2 | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | =head1 METHODS | ||||||||||||||||||||
| 74 | |||||||||||||||||||||
| 75 | =head2 perform_discovery | ||||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | Performs OpenID endpoint discovery for generic OpenID indentifiers | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | =head1 AUTHOR | ||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | Holger Eiboeck <realholgi@cpan.org> | ||||||||||||||||||||
| 82 | |||||||||||||||||||||
| 83 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | This software is copyright (c) 2013 by Holger Eiboeck. | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||
| 88 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||
| 89 | |||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||