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

Mailing List Archive: ModPerl: ModPerl

Dynamically setting PerlVars in Apache per-request

 

 

ModPerl modperl RSS feed   Index | Next | Previous | View Threaded


tosh at 1200group

Nov 23, 2009, 7:13 AM

Post #1 of 2 (524 views)
Permalink
Dynamically setting PerlVars in Apache per-request

WAS: A better way to handle multiple client authentication?

Yeah I use something similar in another application, but in this
application I actually need to change the Auth_DBI_data_source variable
since the "FROM pwd_table" would actually need to be "FROM
clientA.pwd_table" and I can't see how to set this on the fly. I could
probably also set the: Auth_DBI_pwd_table variable as well, but again
the per-request setting is what's throwing me off.

PerlSetVar Auth_DBI_data_source DBI:mysql:clientA
or
PerlSetVar Auth_DBI_pwd_table clientA.pwd_table

Which is why I thought:

RewriteRule ^/(.+)/$ PerlSetVar Auth_DBI_data_source DBI:mysql:$1

I was hoping a SetEnvIf or IfDefine would work but after reading more
about Apache configuration I see it won't.

Anyway, this is straying too far into Apache territory so I guess I will
just set those variables within a modified Apache::AuthDBI

I guess if anyone already knows an auth module that does that above that
would be awesome, or if anyone knows how to easily change PerlVars on
the fly within the Apache config/htaccess space that's be great,
otherwise it's a small change to the above module.

Thanks again!

Tosh


William T wrote:
> The documentation alludes to the variable 'pwd_whereclause'. If this
> variable is set it will be used in the passwd query. I would try and
> set it per client so that the query gets an additional where clause:
>
> SELECT pwd_field FROM pwd_table WHERE uid_field = user AND client = clientA
>
> ^^^^^^^^^^^^^^^^^^^^^^^^
>
> I havn't actually tried this so I don't know if there are any caveats,
> but from the docs at least it seems possible. The only trick is
> making sure you can reset the pwd_whereclause with each different
> client url, and make client an additional column in your pwd_table.
>
> --
> -wjt
>

--
McIntosh Cooey - Twelve Hundred Group LLC - http://www.1200group.com/


adam.prime at utoronto

Nov 23, 2009, 11:12 AM

Post #2 of 2 (478 views)
Permalink
Re: Dynamically setting PerlVars in Apache per-request [In reply to]

My suggestion would be to subclass AuthDBI to make the constructor
fiddle with the dir_config entries that AuthDBI uses.

See the docs for dir_config (the perl interface to PerlSetVar variables:

http://perl.apache.org/docs/2.0/api/Apache2/ServerUtil.html#C_dir_config_

I have no idea how subclass friendly AuthDBI is or isn't.

Adam



Tosh Cooey wrote:
> WAS: A better way to handle multiple client authentication?
>
> Yeah I use something similar in another application, but in this
> application I actually need to change the Auth_DBI_data_source variable
> since the "FROM pwd_table" would actually need to be "FROM
> clientA.pwd_table" and I can't see how to set this on the fly. I could
> probably also set the: Auth_DBI_pwd_table variable as well, but again
> the per-request setting is what's throwing me off.
>
> PerlSetVar Auth_DBI_data_source DBI:mysql:clientA
> or
> PerlSetVar Auth_DBI_pwd_table clientA.pwd_table
>
> Which is why I thought:
>
> RewriteRule ^/(.+)/$ PerlSetVar Auth_DBI_data_source DBI:mysql:$1
>
> I was hoping a SetEnvIf or IfDefine would work but after reading more
> about Apache configuration I see it won't.
>
> Anyway, this is straying too far into Apache territory so I guess I will
> just set those variables within a modified Apache::AuthDBI
>
> I guess if anyone already knows an auth module that does that above that
> would be awesome, or if anyone knows how to easily change PerlVars on
> the fly within the Apache config/htaccess space that's be great,
> otherwise it's a small change to the above module.
>
> Thanks again!
>
> Tosh
>
>
> William T wrote:
>> The documentation alludes to the variable 'pwd_whereclause'. If this
>> variable is set it will be used in the passwd query. I would try and
>> set it per client so that the query gets an additional where clause:
>>
>> SELECT pwd_field FROM pwd_table WHERE uid_field = user AND client =
>> clientA
>>
>> ^^^^^^^^^^^^^^^^^^^^^^^^
>>
>> I havn't actually tried this so I don't know if there are any caveats,
>> but from the docs at least it seems possible. The only trick is
>> making sure you can reset the pwd_whereclause with each different
>> client url, and make client an additional column in your pwd_table.
>>
>> --
>> -wjt
>>
>

ModPerl modperl 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.