-#!/usr/bin/perl
-
package Catalyst::Plugin::Authentication::Credential::HTTP;
-use base qw/Catalyst::Plugin::Authentication::Credential::Password/;
-
-use strict;
-use warnings;
-
-use String::Escape ();
-use URI::Escape ();
-use Catalyst ();
-
-our $VERSION = "0.01";
-
-sub authenticate_http {
- my $c = shift;
-
- my $headers = $c->req->headers;
-
- if ( my ( $user, $password ) = $headers->authorization_basic ) {
-
- if ( my $store = $c->config->{authentication}{http}{store} ) {
- $user = $store->get_user($user);
- }
-
- return $c->login( $user, $password );
- }
-}
-
-sub authorization_required {
- my ( $c, %opts ) = @_;
+use base qw/Catalyst::Authentication::Credential::HTTP/;
- return 1 if $c->authenticate_http;
+our $VERSION = '0.11';
- $c->authorization_required_response( %opts );
+# FIXME - Add a warning here?
+# FIXME - Is this package even needed?
- die $Catalyst::DETACH;
-}
-
-sub authorization_required_response {
- my ( $c, %opts ) = @_;
-
- $c->res->status(401);
-
- my @opts;
-
- if ( my $realm = $opts{realm} ) {
- push @opts, sprintf 'realm=%s', String::Escape::qprintable($realm);
- }
-
- if ( my $domain = $opts{domain} ) {
- Catalyst::Excpetion->throw("domain must be an array reference")
- unless ref($domain) && ref($domain) eq "ARRAY";
-
- my @uris =
- $c->config->{authentication}{http}{use_uri_for}
- ? ( map { $c->uri_for($_) } @$domain )
- : ( map { URI::Escape::uri_escape($_) } @$domain );
-
- push @opts, qq{domain="@uris"};
- }
-
- $c->res->headers->www_authenticate(join " ", "Basic", @opts);
-}
-
-__PACKAGE__;
+1;
__END__
=head1 NAME
-Catalyst::Plugin::Authentication::Credential::HTTP - HTTP Basic authentication
-for Catlayst.
+Catalyst::Plugin::Authentication::Credential::HTTP - HTTP Basic and Digest authentication
+for Catalyst.
=head1 SYNOPSIS
- use Catalyst qw/
+ use Catalyst qw/
Authentication
- Authentication::Store::Moose
+ Authentication::Store::Minimal
Authentication::Credential::HTTP
/;
- sub foo : Local {
- my ( $self, $c ) = @_;
-
- $c->authorization_requried( realm => "foo" ); # named after the status code ;-)
-
- # either user gets authenticated or 401 is sent
-
- do_stuff();
- }
-
- # with ACL plugin
- __PACKAGE__->deny_access_unless("/path", sub { $_[0]->authenticate_http });
-
- sub end : Private {
- my ( $self, $c ) = @_;
-
- $c->authorization_required_response( realm => "foo" );
- $c->error(0);
- }
-
=head1 DESCRIPTION
-This moduule lets you use HTTP authentication with
-L<Catalyst::Plugin::Authentication>.
-
-Currently this module only supports the Basic scheme, but upon request Digest
-will also be added. Patches welcome!
-
-=head1 METHODS
-
-=over 4
-
-=item authorization_required
+This module is deprecated. Please see L<Catalyst::Authentication::Credential::HTTP>
-Tries to C<authenticate_http>, and if that files calls
-C<authorization_required_response> and detaches the current action call stack.
+=head1 AUTHORS
-=item authenticate_http
+Yuval Kogman, C<nothingmuch@woobling.org>
-Looks inside C<< $c->request->headers >> and processes the basic (badly named)
-authorization header.
+Jess Robinson
-=item authorization_required_response
+Sascha Kiefer C<esskar@cpan.org>
-Sets C<< $c->response >> to the correct status code, and adds the correct
-header to demand authentication data from the user agent.
+Tomas Doran C<bobtfish@bobtfish.net>
-=back
+=head1 SEE ALSO
-=head1 AUTHORS
-
-Yuval Kogman, C<nothingmuch@woobling.org>
-
-Jess Robinson
+L<Catalyst::Authentication::Credential::HTTP>.
=head1 COPYRIGHT & LICENSE
- Copyright (c) 2005 the aforementioned authors. All rights
+ Copyright (c) 2005-2006 the aforementioned authors. All rights
reserved. This program is free software; you can redistribute
it and/or modify it under the same terms as Perl itself.
=cut
-