pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in harmony! How?
4+ messages / 2 participants
[nested] [flat]

* Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in harmony! How?
@ 2004-08-17 14:40 Mark Gibson <gibsonm@cromwell.co.uk>
  2004-08-17 15:53 ` Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in Mark Gibson <gibsonm@cromwell.co.uk>
  2004-08-17 16:02 ` Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in Mark Gibson <gibsonm@cromwell.co.uk>
  0 siblings, 2 replies; 4+ messages in thread

From: Mark Gibson @ 2004-08-17 14:40 UTC (permalink / raw)
  To: pgsql-admin@postgresql.org; pgsql-php

Hi,
    I've been trying to Kerberize our Apache and PostgreSQL servers for
our company's web applications.

Goal: To connect from a PHP web app to a PostgreSQL database
using the users credentials, so all authorization is managed via
privileges within the database.

Our IT dept has recently installed Windows 2003 Server to provide
authentication & directories via Kerberos and LDAP.

I've managed to configure Apache (2.0.49) to authenticate users using
mod_auth_kerb (5.0-rc6), and also PostgreSQL (7.4.3) to use Kerberos.
(Linux hosts use MIT KerberosV5 1.3.3 client libs, KDC is Windows 2003)

mod_auth_kerb is configured with:

KrbSaveCredentials on

So in PHP (4.3.8) we end up with the variables:

$_SERVER['REMOTE_USER']    (eg: 'gibsonm@OUR-REALM.CO.UK')
$_SERVER['KRB5CCNAME']     (eg: 'FILE:/tmp/krb5cc_apache_tVFJCd')

Even HTTP Negotiate works with Firefox/Linux (but not IE/XP yet!) :)

But this is where I get stuck.
How do I use the supplied credentials file to connect to PostgreSQL?

In the PostgreSQL docs it says:
(http://www.postgresql.org/docs/7.4/interactive/auth-methods.html#KERBEROS-AUTH)

 > If you use mod_auth_kerb from http://modauthkerb.sf.net and mod_perl
 > on your Apache web server, you can use AuthType
 > KerberosV5SaveCredentials with a mod_perl script. This gives secure
 > database access over the web, no extra passwords required.

I'm assuming this is out of date, or has changed with mod_auth_kerb 5.0,
and that the KrbSaveCredentials directive does this job instead.

Is there any examples of this mod_perl script?
Can the alleged mod_perl method be adapted to PHP?
Has anyone got this to work?
What are the alternatives to my goal stated above?

Cheers
-- 
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in
  2004-08-17 14:40 Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in harmony! How? Mark Gibson <gibsonm@cromwell.co.uk>
@ 2004-08-17 15:53 ` Mark Gibson <gibsonm@cromwell.co.uk>
  1 sibling, 0 replies; 4+ messages in thread

From: Mark Gibson @ 2004-08-17 15:53 UTC (permalink / raw)
  To: Mark Gibson <gibsonm@cromwell.co.uk>; +Cc: pgsql-admin@postgresql.org; pgsql-php

Mark Gibson wrote:
> Hi,
>    I've been trying to Kerberize our Apache and PostgreSQL servers for
> our company's web applications.
> 
> Goal: To connect from a PHP web app to a PostgreSQL database
> using the users credentials, so all authorization is managed via
> privileges within the database.
> 
> Our IT dept has recently installed Windows 2003 Server to provide
> authentication & directories via Kerberos and LDAP.
> 
> I've managed to configure Apache (2.0.49) to authenticate users using
> mod_auth_kerb (5.0-rc6), and also PostgreSQL (7.4.3) to use Kerberos.
> (Linux hosts use MIT KerberosV5 1.3.3 client libs, KDC is Windows 2003)
> 
> mod_auth_kerb is configured with:
> 
> KrbSaveCredentials on
> 
> So in PHP (4.3.8) we end up with the variables:
> 
> $_SERVER['REMOTE_USER']    (eg: 'gibsonm@OUR-REALM.CO.UK')
> $_SERVER['KRB5CCNAME']     (eg: 'FILE:/tmp/krb5cc_apache_tVFJCd')
> 
> Even HTTP Negotiate works with Firefox/Linux (but not IE/XP yet!) :)
> 
> But this is where I get stuck.
> How do I use the supplied credentials file to connect to PostgreSQL?
> 
> In the PostgreSQL docs it says:
> (http://www.postgresql.org/docs/7.4/interactive/auth-methods.html#KERBEROS-AUTH) 
> 
> 
>  > If you use mod_auth_kerb from http://modauthkerb.sf.net and mod_perl
>  > on your Apache web server, you can use AuthType
>  > KerberosV5SaveCredentials with a mod_perl script. This gives secure
>  > database access over the web, no extra passwords required.
> 
> I'm assuming this is out of date, or has changed with mod_auth_kerb 5.0,
> and that the KrbSaveCredentials directive does this job instead.

I'VE DONE IT! THE HOLY GRAIL OF WEB/DB APPS! :)

All it takes it this line your PHP script:

  putenv("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");

Then pg_connect works :)

-- 
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in
  2004-08-17 14:40 Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in harmony! How? Mark Gibson <gibsonm@cromwell.co.uk>
@ 2004-08-17 16:02 ` Mark Gibson <gibsonm@cromwell.co.uk>
  2004-08-17 21:50   ` Re: Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in "Miguel A. Arévalo" <marevalo@marevalo.net>
  1 sibling, 1 reply; 4+ messages in thread

From: Mark Gibson @ 2004-08-17 16:02 UTC (permalink / raw)
  To: ; +Cc: pgsql-admin@postgresql.org; pgsql-php

Mark Gibson wrote:
> Mark Gibson wrote:
> 
>> Hi,
>>    I've been trying to Kerberize our Apache and PostgreSQL servers for
>> our company's web applications.
[snip]
> 
> I'VE DONE IT! THE HOLY GRAIL OF WEB/DB APPS! :)
> 
> All it takes it this line your PHP script:
> 
>  putenv("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");
> 
> Then pg_connect works :)

Or, not, as the case may be.
Well, sometimes it connects and sometimes it doesn't,
PostgreSQL logs the following error:

Kerberos recvauth returned error 103

Any ideas???

-- 
Mark Gibson <gibsonm |AT| cromwell |DOT| co |DOT| uk>
Web Developer & Database Admin
Cromwell Tools Ltd.
Leicester, England.



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in
  2004-08-17 14:40 Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in harmony! How? Mark Gibson <gibsonm@cromwell.co.uk>
  2004-08-17 16:02 ` Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in Mark Gibson <gibsonm@cromwell.co.uk>
@ 2004-08-17 21:50   ` "Miguel A. Arévalo" <marevalo@marevalo.net>
  0 siblings, 0 replies; 4+ messages in thread

From: "Miguel A. Arévalo" @ 2004-08-17 21:50 UTC (permalink / raw)
  To: pgsql-php

AFAIK, redirecting credentials is not supported in mod_auth_krb.

I remember listening something that makes it impossible due to way 
Linux/UNIX works, but don't take this as something more than a rumor.

Regards.

Mark Gibson wrote:
> Mark Gibson wrote:
> 
>> Mark Gibson wrote:
>>
>>> Hi,
>>>    I've been trying to Kerberize our Apache and PostgreSQL servers for
>>> our company's web applications.
> 
> [snip]
> 
>>
>> I'VE DONE IT! THE HOLY GRAIL OF WEB/DB APPS! :)
>>
>> All it takes it this line your PHP script:
>>
>>  putenv("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");
>>
>> Then pg_connect works :)
> 
> 
> Or, not, as the case may be.
> Well, sometimes it connects and sometimes it doesn't,
> PostgreSQL logs the following error:
> 
> Kerberos recvauth returned error 103
> 
> Any ideas???
> 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-08-17 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-08-17 14:40 Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in harmony! How? Mark Gibson <gibsonm@cromwell.co.uk>
2004-08-17 15:53 ` Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in Mark Gibson <gibsonm@cromwell.co.uk>
2004-08-17 16:02 ` Re: [PHP] Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in Mark Gibson <gibsonm@cromwell.co.uk>
2004-08-17 21:50   ` Re: Kerberos, Apache2, mod_auth_kerb, PHP, and PostgreSQL in "Miguel A. Arévalo" <marevalo@marevalo.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox