473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Forwarding kerberos credentials

Hi,
I'm having intermittent problems connecting to my PostgreSQL database
from PHP, using Kerberos credentials forwarded from mod_auth_kerb.

- User authenticates via mod_auth_kerb,
(either Basic or Negotiate HTTP authenication)

- Kerberos credentials are stored in a file that lives for the lifetime
of the HTTP connection.

- PHP is passed a variable naming this file:
$_SERVER['KRB5CCNAME']
(eg. 'FILE:/tmp/krb5cc_apache_RcuW4s')

- Environment variable is set from PHP:
putenv("KRB5CCNAME={$_SERVER['KRB5CCNAME']}");

- Connection to PostgreSQL is attempted from PHP:
pg_connect("host=db.example.com dbname=krbtest user={$user}");

The trouble is that sometimes the connection works,
and sometimes it doesn't. It's very unpredictable. :(

Connecting with psql/kerberos works every time!

Does anyone have an idea of what could cause this?
Has anyone else tried this connection method and got it to work?

Tested on:
RedHat Enterprise Linux 3 & Gentoo Linux
Apache 2.0.46 & 2.0.49 (prefork)
mod_auth_kerb 5.0-rc5 & rc6
PHP 4.3.8
PostgreSQL 7.4.3
MIT KerberosV5 libs 1.3.3 & 1.3.4

Here is the test script I used:

<?php
$m = array();
# Remove kerberos realm from username
if (preg_match('#^(.+?)[/@]#', $_SERVER['REMOTE_USER'], $m)) {
$user = $m[1];
} else {
$user = 'guest';
}

echo "\nPID: ", getmypid(), "\n";

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

$cmd = "/usr/bin/klist";

echo "\n{$cmd}:\n";
passthru($cmd);

$connstr = "host=db.example.com dbname=krb user={$user}";

echo "\nConnection String:\n{$connstr}\n\n";

$db = pg_connect($connstr);

$res = pg_query($db,"SELECT current_user, session_user;");

print_r(pg_fetch_all($res));

pg_close($db);
?>

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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #1
1 3814
Mark Gibson wrote:
Hi,
I'm having intermittent problems connecting to my PostgreSQL database
from PHP, using Kerberos credentials forwarded from mod_auth_kerb. [snip] The trouble is that sometimes the connection works,
and sometimes it doesn't. It's very unpredictable. :(
Oh, I forgot to mention, PostgreSQL logs the following error:

Kerberos recvauth returned error 103

I've searched kerberos errors to find that code 103 isn't defined!
Tested on:
RedHat Enterprise Linux 3 & Gentoo Linux
Apache 2.0.46 & 2.0.49 (prefork)
mod_auth_kerb 5.0-rc5 & rc6
PHP 4.3.8
PostgreSQL 7.4.3
MIT KerberosV5 libs 1.3.3 & 1.3.4


....and the KDC is on a Windows 2003 Server
(I have no control over this)

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

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andreas Schmid | last post by:
Hi, I try to run the example from http://java.sun.com/products/jndi/tutorial/ldap/security/gssapi.html The login on Kerberos succeeds and i get this ticket: Principal: user@MY-DOMAIN.ORG...
3
by: Jacob | last post by:
Hello All, I am trying to serve out some content via IIS that is hosted on a remote fileserver, and am unable to get the delegation working correctly. Our setup is as follows: Local LAN...
2
by: josh | last post by:
Hello Sharepoint Guru's, I have hit a bit of a brick wall in regards to Kerberos authentication. I have an ASP.Net web application that interfaces with sharepoint, this all works fine if I do...
3
by: David | last post by:
Hi, I've had a quick look but cannot find a module that will let me authenticate against Kerberos. There appears to be a krb5 module that hasn't been updated for a long time and I can't find...
1
by: russell.lane | last post by:
I've established user login identity impersonation and delegation for a multi-tier web application. I'm running into a case where authentication fails when a user accesses the app from a browser...
0
by: newjazzharmony | last post by:
We have both Windows and Linux webservers in our organization. I know that WSE 3.0 allows you to secure a web service with Kerberos such that an authenticated NT user can be recognized by the...
0
by: Anbu | last post by:
I already posted this message on usenet groups. But no response. I'm trying with the Microsoft community now, hoping to get some resolution. I have an Intermediate Web service developed using...
2
by: Tapio Kulmala | last post by:
Hi! I've found an interesting problem that might have something to do with Kerberos. I have a www application running in a Windows Server 2003 box. The server did not have SP1 or SP2...
1
by: Ben | last post by:
Hi, i'm trying to implement WSE3 to secure a web service via Kerberos. i used the example at: C:\Program Files\Microsoft WSE\v3.0\Samples\CS \QuickStart\Security\WSSecurityKerberos\Code ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.