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: Platform-independent SSPI authentication support
Date: Tue, 10 Jan 2012 14:07:10 +0100
Message-ID: <jehd5v$1ht$1@dough.gmane.org> (raw)

[A year has gone by since I last posted this message with no
  response (maybe because it didn't show up on the list either), so
  I'm trying again.]

The attached patch provides platform-independent support for the SSPI 
authentication method (that is only supported by servers running on 
Windows) in the JDBC driver. Please note that this patch supports SSPI 
authentication by using the existing GSSAPI code, it does _not_ 
require the underlying system to know anything about SSPI.

I should also point out that GSSAPI support has been removed from the 
PostgreSQL binary installers for Windows in version 9.0, so there is 
currently no authentication method available in these builds that 
supports passwordless authentication via the JDBC driver.

The patch applies against REL9_1_STABLE, as well as CVS trunk. I have 
not tested it in a while, but last year, the resulting driver worked 
on both Windows 7 and Windows XP SP3 clients in a domain with a 
Windows 2008 DC, accessing PostgreSQL 8.4.4 and 9.0.2 on a Windows 
2008 server, and there has been very little change in the affected 
code. The equivalent change to libpq, which has been released in 
9.1.2, worked in all environments I tested in. [1]

The patch does two things:

- It adds client-side SSPI support in the simplest possible way: by
   acting as if it was the same as GSSAPI. This works 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). This is the documented behavior of the Negotiate
   SSP, it is not a compatilibity quirk.

- It improves on that 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, authentication succeeds even with
   "sun.security.spnego.msinterop=false", if that even has any effect.

[1] 
<http://archives.postgresql.org/message-id/4D3C42F3.4080503@chrullrich.net;

Attachments:

jdbc-sspi.patch (text/plain, 1.7K) download --- a/org/postgresql/core/v3/ConnectionFactoryImpl.java Tue Jan 10 13:23:17 2012 +0100 +++ b/org/postgresql/core/v3/ConnectionFactoryImpl.java Thu Oct 28 16:04:14 2010 +0200 @@ -377,6 +377,7 @@ } case AUTH_REQ_GSS: + case AUTH_REQ_SSPI: org.postgresql.gss.MakeGSS.authenticate(pgStream, host, user, password, info.getProperty("jaasApplicationName"), @@ -384,12 +385,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"); --- a/org/postgresql/gss/MakeGSS.java Tue Jan 10 13:23:17 2012 +0100 +++ b/org/postgresql/gss/MakeGSS.java Thu Oct 28 16:04:14 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();

view thread (4+ messages)  latest in thread

Message-ID: <jehd5v$1ht$1@dough.gmane.org>
Permalink:  ../jehd5v$1ht$1@dough.gmane.org/
Also on:    postgresql.org/message-id/jehd5v$1ht$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: Platform-independent SSPI authentication support
  In-Reply-To: <jehd5v$1ht$1@dough.gmane.org>
  References: <jehd5v$1ht$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