<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
I'm developing an app which uses IIS and FastCGI as its back end. Also,
we are expected by the client to use Windows integrated authentication
in the server -- this is an intranet app, so no login screen should be
expected. <br>
<br>
Picking up the user id is fairly easy - it's set as the REMOTE_USER CGI
header by IIS authentication, and the engine puts it into the
deprecated $c-&gt;request-&gt;user. I was using this as the identity
(bad, I know) and got burned by the fact that we couldn't properly test
multiple users with Test::WWW::Mechanize::Catalyst. <br>
<br>
I wanted to switch to Catalyst::Plugin::Authentication. This seemed a
little unusual when we aren't really doing any authentication, but
trying to read the one already performed, so I put together a
Catalyst::Authentication::Credential::Environment module, that simply
reads (the still deprecated) $c-&gt;request-&gt;user. I didn't really
want to do all the authentication with
Catalyst::Plugin::Authentication, even though is seems possible. And
testing was now easy, we got per-user sessions, and everything. Anyway,
what I wrote as the main method was:<br>
<br>
<tt>sub authenticate {<br>
&nbsp;&nbsp;&nbsp; my ( $self, $c, $realm, $auth_info ) = @_;<br>
&nbsp;&nbsp;&nbsp; $c-&gt;log-&gt;debug("Using environment authentication");<br>
&nbsp;&nbsp;&nbsp; my $username = $c-&gt;request-&gt;user();<br>
&nbsp;&nbsp;&nbsp; if ( defined( $username ) &amp;&amp; ( $username ne '' )) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; my $user_obj = $realm-&gt;find_user( { username =&gt; $username
}, $c );<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( ref( $user_obj ) ) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $user_obj-&gt;id( $username );<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $user_obj;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; }<br>
&nbsp;&nbsp;&nbsp; return;<br>
}</tt><br>
<br>
Is there another simple but better way to achieve this? Ideally one
which avoids the deprecated $c-&gt;request-&gt;user. I'm only starting
to use Catalyst for authentication stuff. <br>
<br>
All the best<br>
Stuart<br>
<div class="moz-signature">-- <br>
<span style="color: rgb(102, 0, 0);">Stuart Watt<br>
ARM Product Developer<br>
Information Balance</span></div>
</body>
</html>