if ( my ( $username, $password ) = $headers->authorization_basic ) {
my $user_obj = $realm->find_user( { $self->_config->{username_field} => $username }, $c);
- if (ref($user_obj)) {
- if ($self->check_password($user_obj, {$self->_config->{password_field} => $password})) {
+ if (ref($user_obj)) {
+ my $opts = {};
+ $opts->{$self->_config->{password_field}} = $password
+ if $self->_config->{password_field};
+ if ($self->check_password($user_obj, $opts)) {
$c->set_authenticated($user_obj);
return $user_obj;
}
/;
__PACKAGE__->config( authentication => {
+ default_realm => 'example',
realms => {
example => {
credential => {
$c->authenticate({ realm => "example" });
# either user gets authenticated or 401 is sent
- # Note that the authentication realm sent to the client is overridden
- # here, but this does not affect the Catalyst::Authentication::Realm
- # used for authentication.
+ # Note that the authentication realm sent to the client (in the
+ # RFC 2617 sense) is overridden here, but this *does not*
+ # effect the Catalyst::Authentication::Realm used for
+ # authentication - to do that, you need
+ # $c->authenticate({}, 'otherrealm')
do_stuff();
}