Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 192171E16586 for ; Tue, 10 Jan 2012 09:07:43 -0400 (AST) Received: from lo.gmane.org ([80.91.229.12]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RkbQS-0007QF-Q2 for pgsql-jdbc@postgresql.org; Tue, 10 Jan 2012 13:07:42 +0000 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1RkbQG-0004Sy-FA for pgsql-jdbc@postgresql.org; Tue, 10 Jan 2012 14:07:28 +0100 Received: from 217.31.70.82 ([217.31.70.82]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Jan 2012 14:07:28 +0100 Received: from chris by 217.31.70.82 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 10 Jan 2012 14:07:28 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Christian Ullrich Subject: Patch: Platform-independent SSPI authentication support Date: Tue, 10 Jan 2012 14:07:10 +0100 Lines: 87 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------040301080307020109080901" X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 217.31.70.82 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 X-Pg-Spam-Score: -3.0 (---) X-Archive-Number: 201201/43 X-Sequence-Number: 22583 This is a multi-part message in MIME format. --------------040301080307020109080901 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit [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] --------------040301080307020109080901 Content-Type: text/plain; name="jdbc-sspi.patch" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="jdbc-sspi.patch" LS0tIGEvb3JnL3Bvc3RncmVzcWwvY29yZS92My9Db25uZWN0aW9uRmFjdG9yeUltcGwuamF2 YQlUdWUgSmFuIDEwIDEzOjIzOjE3IDIwMTIgKzAxMDAKKysrIGIvb3JnL3Bvc3RncmVzcWwv Y29yZS92My9Db25uZWN0aW9uRmFjdG9yeUltcGwuamF2YQlUaHUgT2N0IDI4IDE2OjA0OjE0 IDIwMTAgKzAyMDAKQEAgLTM3Nyw2ICszNzcsNyBAQAogICAgICAgICAgICAgICAgICAgICB9 DQogDQogICAgICAgICAgICAgICAgIGNhc2UgQVVUSF9SRVFfR1NTOg0KKyAgICAgICAgICAg ICAgICBjYXNlIEFVVEhfUkVRX1NTUEk6DQogICAgICAgICAgICAgICAgICAgICBvcmcucG9z dGdyZXNxbC5nc3MuTWFrZUdTUy5hdXRoZW50aWNhdGUocGdTdHJlYW0sIGhvc3QsDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgIHVzZXIsIHBhc3N3b3JkLCANCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgaW5mby5nZXRQcm9wZXJ0eSgiamFhc0FwcGxpY2F0aW9uTmFt ZSIpLA0KQEAgLTM4NCwxMiArMzg1LDYgQEAKICAgICAgICAgICAgICAgICAgICAgICAgICAg ICBsb2dnZXIpOw0KICAgICAgICAgICAgICAgICAgICAgYnJlYWs7DQogDQotICAgICAgICAg ICAgICAgIGNhc2UgQVVUSF9SRVFfU1NQSToNCi0gICAgICAgICAgICAgICAgICAgIGlmIChs b2dnZXIubG9nRGVidWcoKSkNCi0gICAgICAgICAgICAgICAgICAgICAgICBsb2dnZXIuZGVi dWcoIiA8PUJFIEF1dGhlbnRpY2F0aW9uUmVxU1NQSSIpOw0KLQ0KLSAgICAgICAgICAgICAg ICAgICAgdGhyb3cgbmV3IFBTUUxFeGNlcHRpb24oR1QudHIoIlNTUEkgYXV0aGVudGljYXRp b24gaXMgbm90IHN1cHBvcnRlZCBiZWNhdXNlIGl0IGlzIG5vdCBwb3J0YWJsZS4gIFRyeSBj b25maWd1cmluZyB0aGUgc2VydmVyIHRvIHVzZSBHU1NBUEkgaW5zdGVhZC4iKSwgUFNRTFN0 YXRlLkNPTk5FQ1RJT05fUkVKRUNURUQpOw0KLQ0KICAgICAgICAgICAgICAgICBjYXNlIEFV VEhfUkVRX09LOg0KICAgICAgICAgICAgICAgICAgICAgaWYgKGxvZ2dlci5sb2dEZWJ1Zygp KQ0KICAgICAgICAgICAgICAgICAgICAgICAgIGxvZ2dlci5kZWJ1ZygiIDw9QkUgQXV0aGVu dGljYXRpb25PayIpOw0KLS0tIGEvb3JnL3Bvc3RncmVzcWwvZ3NzL01ha2VHU1MuamF2YQlU dWUgSmFuIDEwIDEzOjIzOjE3IDIwMTIgKzAxMDAKKysrIGIvb3JnL3Bvc3RncmVzcWwvZ3Nz L01ha2VHU1MuamF2YQlUaHUgT2N0IDI4IDE2OjA0OjE0IDIwMTAgKzAyMDAKQEAgLTgzLDgg KzgzLDkgQEAKIA0KICAgICAgICAgdHJ5IHsNCiANCi0gICAgICAgICAgICBvcmcuaWV0Zi5q Z3NzLk9pZCBkZXNpcmVkTWVjaHNbXSA9IG5ldyBvcmcuaWV0Zi5qZ3NzLk9pZFsxXTsNCi0g ICAgICAgICAgICBkZXNpcmVkTWVjaHNbMF0gPSBuZXcgb3JnLmlldGYuamdzcy5PaWQoIjEu Mi44NDAuMTEzNTU0LjEuMi4yIik7DQorICAgICAgICAgICAgb3JnLmlldGYuamdzcy5PaWQg ZGVzaXJlZE1lY2hzW10gPSBuZXcgb3JnLmlldGYuamdzcy5PaWRbMl07DQorICAgICAgICAg ICAgZGVzaXJlZE1lY2hzWzBdID0gbmV3IG9yZy5pZXRmLmpnc3MuT2lkKCIxLjMuNi4xLjUu NS4yIik7DQorICAgICAgICAgICAgZGVzaXJlZE1lY2hzWzFdID0gbmV3IG9yZy5pZXRmLmpn c3MuT2lkKCIxLjIuODQwLjExMzU1NC4xLjIuMiIpOw0KIA0KIA0KICAgICAgICAgICAgIEdT U01hbmFnZXIgbWFuYWdlciA9IEdTU01hbmFnZXIuZ2V0SW5zdGFuY2UoKTsNCg== --------------040301080307020109080901--