473,592 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_R cuW4s')

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

- Connection to PostgreSQL is attempted from PHP:
pg_connect("hos t=db.example.co m 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("KRB5CCN AME={$_SERVER['KRB5CCNAME']}");

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

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

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

echo "\nConnecti on String:\n{$conn str}\n\n";

$db = pg_connect($con nstr);

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

print_r(pg_fetc h_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 3839
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
8167
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 Private Authentisierung: Ticket (hex) = 0000: 61 81 EF 30 81 EC A0 03 02 01 05 A1 0F 1B 0D 4D
3
5217
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 Windows 2000 domain (mixed-mode): MYDOMAIN (mydomain.net) Windows 2003 Server w/IIS6: WEB01 Windows 2000 Server hosting files: FILE01 Windows XP Pro client workstation: CLIENT01
2
1652
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 this dws.Credentials = new NetworkCredential("sk", _SPSPassword, _SPSDomain); however when I tray and pass the default credentials it won't work. I have
3
6967
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 much on it except the pages at starship.python.net. I don't need to do anything except authenticate and gain the correct credentials.
1
2718
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 on one machine, but not from another machine. The relevant details -- in both cases, all of the following are in effect: Same user account. Same web application, same IIS host. Client OS is XP Pro SP2.
0
944
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 webservice without being challenged for credentials. Is there a way for a Linux client to be authenticated by the same webservice? Thanks, Jonathan
0
1050
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 .NET and WSE 3.0 between a Java service and .NET Client. The client works, similar to Digest authentication (which first sends data without credentials, but later on will send data with credentials based on the output - HTTP response code). The...
2
1679
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 installed. Everything was working smoothly. Couple days ago we installed SP2 and weird authentication errors started to occur occasionally.
1
2061
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 but i get this error:
0
7935
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7871
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6642
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2379
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1202
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.