[Catalyst] How to return a 401 from Catalyst
Ian Docherty
catalyst at iandocherty.com
Sat Jan 26 13:39:04 GMT 2008
Related to my earlier thread about basic authentication, what do I have
to do to return a 401 error from within Catalyst?
I have tried to understand the documentation at
http://www.ietf.org/rfc/rfc2617.txt but it does not help me in a
practical manner.
My understanding is that when the Catalyst app refuses the credentials
given it must return a 401 with a 'realm' that is
just a string used to identify the service.
For example, when I create a test script for my Controller using LWP as
follows
my $ua = LWP::UserAgent->new;
$ua->credentials('linux:8001','some_realm_or_other','sage_1001','sage');
Then my script fails because I have not set a 'realm' correctly in my
Catalyst controller. All I have done so far is as follows.
if ($login_success) ) {
# do something
}
else {
$c->response->status(401);
return 0;
}
Obviously I need to do more to return the realm, but what exactly?
Regards
Ian
p.s. I note that there is nothing in Test::WWW (that I can find) that
tests return status's such as 200, 401 etc.
More information about the Catalyst
mailing list