| 1 | package Catalyst::Plugin::Authentication::Store::HTTP::User; | ||
| 2 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use base qw/Catalyst::Plugin::Authentication::User Class::Accessor::Fast/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | use Catalyst::Plugin::Authentication::Store::HTTP::UserAgent; | ||
| 7 | |||
| 8 | __PACKAGE__->mk_accessors(qw/id store/); | ||
| 9 | |||
| 10 | use overload q{""} => sub { shift->id }, fallback => 1; | ||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | Catalyst::Plugin::Authentication::Store::HTTP::User - HTTP authentication storage user class | ||
| 15 | |||
| 16 | =head1 SYNOPSIS | ||
| 17 | |||
| 18 | See L<Catalyst::Plugin::Authentication::Store::HTTP>. | ||
| 19 | |||
| 20 | =head1 DESCRIPTION | ||
| 21 | |||
| 22 | HTTP authentication storage user class | ||
| 23 | |||
| 24 | =head1 METHODS | ||
| 25 | |||
| 26 | =head2 supported_features | ||
| 27 | |||
| 28 | =cut | ||
| 29 | |||
| 30 | sub supported_features { | ||
| 31 | return { | ||
| 32 | password => { self_check => 1, }, | ||
| 33 | session => 1, | ||
| 34 | }; | ||
| 35 | } | ||
| 36 | |||
| 37 | =head2 check_password | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | sub check_password { | ||
| 42 | my ($self, $password) = @_; | ||
| 43 | |||
| 44 | my $ua = | ||
| 45 | Catalyst::Plugin::Authentication::Store::HTTP::UserAgent->new( | ||
| 46 | keep_alive => ($self->{keep_alive} ? 1 : 0)); | ||
| 47 | my $req = HTTP::Request->new(HEAD => $self->{auth_url}); | ||
| 48 | |||
| 49 | # set the credentials for the request. | ||
| 50 | # if there is a domain set then prepend this onto the user id | ||
| 51 | $ua->credentials( | ||
| 52 | ($self->{domain} ? join("\\", $self->{domain}, $self->id) : $self->id), | ||
| 53 | $password | ||
| 54 | ); | ||
| 55 | |||
| 56 | my $res = $ua->request($req); | ||
| 57 | |||
| 58 | $res->is_success; | ||
| 59 | } | ||
| 60 | |||
| 61 | =head2 for_session | ||
| 62 | |||
| 63 | =cut | ||
| 64 | |||
| 65 | sub for_session { | ||
| 66 | shift; | ||
| 67 | } | ||
| 68 | |||
| 69 | =head2 from_session | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | sub from_session { | ||
| 74 | my ($self, $c, $user) = @_; | ||
| 75 | |||
| 76 | $user; | ||
| 77 | } | ||
| 78 | |||
| 79 | =head1 AUTHOR | ||
| 80 | |||
| 81 | Daisuke Murase <typester@cpan.org> | ||
| 82 | |||
| 83 | Nigel Metheringham <nigelm@cpan.org> | ||
| 84 | |||
| 85 | =head1 COPYRIGHT | ||
| 86 | |||
| 87 | This program is free software; you can redistribute it and/or modify | ||
| 88 | it under the same terms as Perl itself. | ||
| 89 | |||
| 90 | The full text of the license can be found in the LICENSE file included | ||
| 91 | with this module. | ||
| 92 | |||
| 93 | =cut | ||
| 94 | |||
| 95 | 1; | ||