On Sat, 26 Jan 2008, Ian Docherty wrote:

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?

Use the Authentication::Credential::HTTP module that does it for you?

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.


In general, $c->res->status(401); etc.

JEss

_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to