Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

How to access $c->apache in 5.9?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


i at h2l

Apr 19, 2012, 7:42 PM

Post #1 of 6 (480 views)
Permalink
How to access $c->apache in 5.9?

I'm trying to log username authenticated throught ldap into a log
file, and I use Apache/mod_perl.

In 5.8

$c->apache->user( $username );

works, which doesn't work in 5.9.

I checked source code of relevant modules like
Catalyst
Catalyst::EngineLoader
Catalyst::Upgrading

It seems like that Catalyst::Engine::Apache is not used any more, isn't it?

Finally, something like below works for me.

my $apache = $c->engine->env->{'psgi.input'}; # Apache2::RequestRec
$apache->user( $username );

I supposed that an accessor of apache should be a method instead of a
key of hash.
Is this the right way to retrieve the apache/mod_perl object?

Thanks.

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


edencardim at gmail

Apr 20, 2012, 4:56 AM

Post #2 of 6 (461 views)
Permalink
Re: How to access $c->apache in 5.9? [In reply to]

>>>>> "Hailin" == Hailin Hu <i [at] h2l> writes:
Hailin> Finally, something like below works for me.

Hailin> my $apache = $c->engine->env->{'psgi.input'}; #
Hailin> Apache2::RequestRec $apache->user( $username );

Hailin> I supposed that an accessor of apache should be a method instead
Hailin> of a key of hash. Is this the right way to retrieve the
Hailin> apache/mod_perl object?

No it's not, this ties your application to a specific backend server
implementation (which is what caused your problem in the first
place). Whenever you need to access $c->engine->env, you should be applying a
Plack::Middleware to your .psgi instead.

--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://edencardim.com http://www.shadowcat.co.uk/servers/

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


bobtfish at bobtfish

Apr 20, 2012, 5:55 AM

Post #3 of 6 (460 views)
Permalink
Re: How to access $c->apache in 5.9? [In reply to]

On 20 Apr 2012, at 12:56, Eden Cardim wrote:

>>>>>> "Hailin" == Hailin Hu <i [at] h2l> writes:
> Hailin> Finally, something like below works for me.
>
> Hailin> my $apache = $c->engine->env->{'psgi.input'}; #
> Hailin> Apache2::RequestRec $apache->user( $username );
>
> Hailin> I supposed that an accessor of apache should be a method instead
> Hailin> of a key of hash. Is this the right way to retrieve the
> Hailin> apache/mod_perl object?
>
> No it's not, this ties your application to a specific backend server
> implementation (which is what caused your problem in the first
> place). Whenever you need to access $c->engine->env, you should be applying a
> Plack::Middleware to your .psgi instead.

For this specific thing, there is already $c->req->remote_user, which should get this - no?

https://metacpan.org/module/Catalyst::Request#req-remote_user
http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10018/lib/Catalyst/Authentication/Credential/Remote.pm

Cheers
t0m


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


i at h2l

Apr 20, 2012, 7:40 AM

Post #4 of 6 (461 views)
Permalink
Re: How to access $c->apache in 5.9? [In reply to]

I didn't catch you guys. Let me make my problem clearer.

My catalyst application handles the auth process and I want Apache writes
username into its log files, just like using Apache's basic auth module.
2012/04/20 21:59 "Tomas Doran" <bobtfish [at] bobtfish>:

>
> On 20 Apr 2012, at 12:56, Eden Cardim wrote:
>
> >>>>>> "Hailin" == Hailin Hu <i [at] h2l> writes:
> > Hailin> Finally, something like below works for me.
> >
> > Hailin> my $apache = $c->engine->env->{'psgi.input'}; #
> > Hailin> Apache2::RequestRec $apache->user( $username );
> >
> > Hailin> I supposed that an accessor of apache should be a method
> instead
> > Hailin> of a key of hash. Is this the right way to retrieve the
> > Hailin> apache/mod_perl object?
> >
> > No it's not, this ties your application to a specific backend server
> > implementation (which is what caused your problem in the first
> > place). Whenever you need to access $c->engine->env, you should be
> applying a
> > Plack::Middleware to your .psgi instead.
>
> For this specific thing, there is already $c->req->remote_user, which
> should get this - no?
>
> https://metacpan.org/module/Catalyst::Request#req-remote_user
>
> http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10018/lib/Catalyst/Authentication/Credential/Remote.pm
>
> Cheers
> t0m
>
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/
>


i at h2l

Apr 22, 2012, 9:20 PM

Post #5 of 6 (451 views)
Permalink
Re: How to access $c->apache in 5.9? [In reply to]

Finally I solved the problem like this

# somewhere in module like after_login() in Admin.pm
if ( $ENV{ MOD_PERL } ) {
my $r = $c->req->env->{'psgi.input'};
$r->user( $c->user->uid );
}

Since the stuff is engine relevant, maybe it is better to be
implemented in Plack::Handler::Apache2 :)

On Fri, Apr 20, 2012 at 11:40 PM, Hailin Hu <i [at] h2l> wrote:
> I didn't catch you guys. Let me make my problem clearer.
>
> My catalyst application handles the auth process and I want Apache writes
> username into its log files, just like using Apache's basic auth module.
>
> 2012/04/20 21:59 "Tomas Doran" <bobtfish [at] bobtfish>:
>
>>
>> On 20 Apr 2012, at 12:56, Eden Cardim wrote:
>>
>> >>>>>> "Hailin" == Hailin Hu <i [at] h2l> writes:
>> >    Hailin> Finally, something like below works for me.
>> >
>> >    Hailin> my $apache = $c->engine->env->{'psgi.input'}; #
>> >    Hailin> Apache2::RequestRec $apache->user( $username );
>> >
>> >    Hailin> I supposed that an accessor of apache should be a method
>> > instead
>> >    Hailin> of a key of hash.  Is this the right way to retrieve the
>> >    Hailin> apache/mod_perl object?
>> >
>> > No it's not, this ties your application to a specific backend server
>> > implementation (which is what caused your problem in the first
>> > place). Whenever you need to access $c->engine->env, you should be
>> > applying a
>> > Plack::Middleware to your .psgi instead.
>>
>> For this specific thing, there is already $c->req->remote_user, which
>> should get this - no?
>>
>> https://metacpan.org/module/Catalyst::Request#req-remote_user
>>
>> http://search.cpan.org/~bobtfish/Catalyst-Plugin-Authentication-0.10018/lib/Catalyst/Authentication/Credential/Remote.pm
>>
>> Cheers
>> t0m
>>
>>
>> _______________________________________________
>> List: Catalyst [at] lists
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive:
>> http://www.mail-archive.com/catalyst [at] lists/
>> Dev site: http://dev.catalyst.perl.org/

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


edencardim at gmail

Apr 23, 2012, 3:41 AM

Post #6 of 6 (451 views)
Permalink
Re: How to access $c->apache in 5.9? [In reply to]

Hailin> Finally I solved the problem like this

# somewhere in module like after_login() in Admin.pm
if ( $ENV{ MOD_PERL } ) {
my $r = $c->req->env->{'psgi.input'};
$r->user( $c->user->uid );
}

Hailin> Since the stuff is engine relevant, maybe it is better to be
Hailin> implemented in Plack::Handler::Apache2 :)

No, as I've said before, it's better implemented in a middleware.

--
Eden Cardim Need help with your Catalyst or DBIx::Class project?
Code Monkey http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://edencardim.com http://www.shadowcat.co.uk/servers/

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

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.