Catalyst-Authentication-Credential-HTTP
view release on metacpan or search on metacpan
lib/Catalyst/Authentication/Credential/HTTP.pm view on Meta::CPAN
absolute path (starts with /), it is relative to the root URL of the server being accessed.
An absolute URI in this list may refer to a different server than the one being accessed.
The client will use this list to determine the set of URIs for which the same authentication
information may be sent.
If this is omitted or its value is empty, the client will assume that the
protection space consists of all URIs on the responding server.
Therefore, if your application is not hosted at the root of this domain, and you want to
prevent the authentication credentials for this application being sent to any other applications.
then you should use the I<use_uri_for> configuration option, and pass a domain of I</>.
=back
=item authenticate_basic $c, $realm, \%auth_info
Performs HTTP basic authentication.
=item authenticate_digest $c, $realm, \%auth_info
lib/Catalyst/Authentication/Credential/HTTP.pm view on Meta::CPAN
L<Catalyst::Authentication::Credential::Password|Catalyst::Authentication::Credential::Password/password_field>
=item username_field
The field name that the user's username is mapped into when finding the user from the realm. Defaults to 'username'.
=item use_uri_for
If this configuration key has a true value, then the domain(s) for the authorization header will be
run through $c->uri_for(). Use this configuration option if your application is not running at the root
of your domain, and you want to ensure that authentication credentials from your application are not shared with
other applications on the same server.
=item require_ssl
If this configuration key has a true value then authentication will be denied
(and a 401 issued in normal circumstances) unless the request is via https.
=item no_unprompted_authorization_required
Causes authentication to fail as normal modules do, without calling
$c->set_always( request => $req );
$c->set_always( response => $res );
sub new_self {
my $config = { @_ };
my $raw_self = $m->new($config, $c, $realm);
return Test::MockObject::Extends->new( $raw_self );
}
# Normal auth, simple as possible.
# No credentials
my $self = new_self( type => 'any', password_type => 'clear', password_field => 'password' );
throws_ok {
$self->authenticate( $c, $realm );
} qr/^ $Catalyst::DETACH $/x, 'Calling authenticate for http auth without header detaches';
$user->{password} = 'bar';
# Wrong credentials
$req_headers->authorization_basic( qw/foo quux/ );
throws_ok {
$self->authenticate( $c, $realm );
} qr/^ $Catalyst::DETACH $/x, 'Calling authenticate for http auth without header detaches';
# Correct credentials
$req_headers->authorization_basic( qw/foo bar/ );
{
my $user = $self->authenticate($c, $realm);
ok($user, "auth successful with header");
isa_ok $user, 'Catalyst::Authentication::User';
}
is($authenticated, 0, 'Not called set_authenticated');
is_deeply( $find_user_opts, { username => 'foo'}, "login delegated");
# Test all the headers look good.
( run in 0.273 second using v1.01-cache-2.11-cpan-4d50c553e7e )