pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christian Ullrich <chris@chrullrich.net>
To: pgsql-jdbc@postgresql.org
Subject: Patch: SSPI authentication support
Date: Wed, 15 Sep 2010 00:03:44 +0200
Message-ID: <i6org1$mup$1@dough.gmane.org> (raw)

Hello all,

the attached patches provide support for the (Windows-only) SSPI 
authentication method in the JDBC driver. They will need more testing; I 
hope to find some volunteers here. Please note that these patches 
support SSPI authentication by using the existing GSSAPI code, they do 
_not_ require the underlying system to know anything about SSPI.

The patches are based on CVS HEAD. The resulting driver works on both 
Windows 7 and Windows XP SP3 clients in a domain with a Windows 2008 DC, 
accessing PostgreSQL 8.4.4 on a (different) Windows 2008 server. I have 
not tested any other combination of clients and servers, if you have the 
opportunity, please test it on your systems. It would be nice to find 
out if non-Windows systems can log on to Windows servers configured for 
SSPI if they are in the same Kerberos realm.

The first patch, "1-sspi-ConnectionFactoryImpl.patch", adds client-side 
SSPI support in the simplest possible way: by acting as if it was the 
same as GSSAPI. This works, probably because the Negotiate SSP that is 
used by the server for SSPI authentication is clever enough to also 
handle incoming GSSAPI tokens (without SPNEGO encapsulation). Although 
this patch leads to successful authentication, it is therefore not a 
complete solution, because it relies on the Negotiate SSP violating its 
own protocol.

I have only tested the combination of clients and server I described 
above; if you have the opportunity, please test it on your systems.

The second patch, "2-sspi-MakeGSS.patch", improves on the first one by 
adding the OID for the SPNEGO mechanism to the authenticator. This works 
only on Sun Java 1.6 and later; SPNEGO support is not available in 
earlier releases. With this change, the SPNEGO negotiation is actually 
performed on the wire. In my environment, this works even with 
"sun.security.spnego.msinterop=false".


Even though this change resulted in perfect authentication in my 
environment, I keep thinking, "it was too easy". If you agree, please 
let me know what I failed to consider.

-- 
Christian

Attachments: download all (2 files, .tar.gz)

1-sspi-ConnectionFactoryImpl.patch (text/plain, 1.0K) download --- a/org/postgresql/core/v3/ConnectionFactoryImpl.java Tue Sep 14 23:09:00 2010 +0200 +++ b/org/postgresql/core/v3/ConnectionFactoryImpl.java Tue Sep 14 23:09:53 2010 +0200 @@ -375,6 +375,7 @@ } case AUTH_REQ_GSS: + case AUTH_REQ_SSPI: org.postgresql.gss.MakeGSS.authenticate(pgStream, host, user, password, info.getProperty("jaasApplicationName"), @@ -382,12 +383,6 @@ logger); break; - case AUTH_REQ_SSPI: - if (logger.logDebug()) - logger.debug(" <=BE AuthenticationReqSSPI"); - - throw new PSQLException(GT.tr("SSPI authentication is not supported because it is not portable. Try configuring the server to use GSSAPI instead."), PSQLState.CONNECTION_REJECTED); - case AUTH_REQ_OK: if (logger.logDebug()) logger.debug(" <=BE AuthenticationOk");
2-sspi-MakeGSS.patch (text/plain, 613B) download --- a/org/postgresql/gss/MakeGSS.java Tue Sep 14 23:09:53 2010 +0200 +++ b/org/postgresql/gss/MakeGSS.java Tue Sep 14 23:11:11 2010 +0200 @@ -83,8 +83,9 @@ try { - org.ietf.jgss.Oid desiredMechs[] = new org.ietf.jgss.Oid[1]; - desiredMechs[0] = new org.ietf.jgss.Oid("1.2.840.113554.1.2.2"); + org.ietf.jgss.Oid desiredMechs[] = new org.ietf.jgss.Oid[2]; + desiredMechs[0] = new org.ietf.jgss.Oid("1.3.6.1.5.5.2"); + desiredMechs[1] = new org.ietf.jgss.Oid("1.2.840.113554.1.2.2"); GSSManager manager = GSSManager.getInstance();

Message-ID: <i6org1$mup$1@dough.gmane.org>
Permalink:  ../i6org1$mup$1@dough.gmane.org/
Also on:    postgresql.org/message-id/i6org1$mup$1@dough.gmane.org

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: chris@chrullrich.net
  Subject: Re: Patch: SSPI authentication support
  In-Reply-To: <i6org1$mup$1@dough.gmane.org>
  References: <i6org1$mup$1@dough.gmane.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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