Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VquNf-0004Qp-Mw for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Dec 2013 00:43:55 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VquNf-0004SY-6D for pgsql-jdbc@arkaria.postgresql.org; Thu, 12 Dec 2013 00:43:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VquNe-0004SM-7X for pgsql-jdbc@postgresql.org; Thu, 12 Dec 2013 00:43:54 +0000 Received: from smtp1.stanford.edu ([171.67.219.81] helo=smtp.stanford.edu) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VquNa-0006dO-HT for pgsql-jdbc@postgresql.org; Thu, 12 Dec 2013 00:43:53 +0000 Received: from smtp.stanford.edu (localhost [127.0.0.1]) by localhost (Postfix) with SMTP id A300B23567 for ; Wed, 11 Dec 2013 16:43:47 -0800 (PST) Received: from radtke.local (c-50-131-40-145.hsd1.ca.comcast.net [50.131.40.145]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: pradtke) by smtp.stanford.edu (Postfix) with ESMTPSA id 14847216DB for ; Wed, 11 Dec 2013 16:43:47 -0800 (PST) Message-ID: <52A906C1.8030700@stanford.edu> Date: Wed, 11 Dec 2013 16:43:45 -0800 From: Patrick Radtke User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: Service principal, GSSAPI and JDBC connection issue References: <52A25425.8040908@stanford.edu> In-Reply-To: <52A25425.8040908@stanford.edu> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.8 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Is anyone else using GSSAPI authentication? I would like to submit a patch to fix my problem, but I would like someone with a different kerberos setup then me to verify it doesn't cause them issues. thanks, Patrick On 12/6/13, 2:48 PM, Patrick Radtke wrote: > Hi, > > I'm using PostgreSQL 9.1 and I have configured GSSAPI authentication for > my client application. > > The client application has this principal: > service/uaa-authz-uat01@stanford.edu > > and I have it mapped to the DB role/user uaa > > pg_ident.conf > # MAPNAME SYSTEM-USERNAME PG-USERNAME > krb5 service/uaa-authz-uat01 uaa > > Connecting works fine with psql. I use k5start to get the appropriate > tickets and then connect > > k5start -qUf /etc/oauth/keytab -- psql -h authz-uat01 -U uaa > > However, when I try connecting with the JDBC driver I run into trouble. > I've configured my JAAS config > > pgjdbc { > com.sun.security.auth.module.Krb5LoginModule required > principal="service/uaa-authz-uat01" > useKeyTab=true > keyTab="/etc/oauth/keytab" > doNotPrompt=true > useTicketCache=true > storeKey=true > debug=true > renewTGT=true; > }; > > and my JDBC connection with these properties > database: > driverClassName: org.postgresql.Driver > url: > jdbc:postgresql://authz-uat01.stanford.edu/uaa?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory > > username: uaa > > > however when I go to connect I get the error > "No valid credentials provided (Mechanism level: Failed to find any > Kerberos tgt)" which is odd because in the JAAS debug output it seems to > be able to create a tgt based on the keytab just fine. > > Reviewing the code in 'MakeGSS.java' I see the problem. > > GSSName clientName = manager.createName(user, GSSName.NT_USER_NAME); > > GSSCredential clientCreds = manager.createCredential(clientName, 8*3600, > desiredMechs, GSSCredential.INITIATE_ONLY); > > The driver assumes that the client is a 'GSSName.NT_USER_NAME' which is > "Name type to indicate a named user on a local system.". It passes in > 'uaa' (the username) to createName(), and then the next call to > createCredential() fails since the tgt is for 'service/uaa-authz-uat01' > and its looking for one that matches 'uaa'. > > Setting the db username to 'service/uaa-authz-uat01' gets by the GSSAPI > issues, but then fails because I don't have (nor wish to have) a > postgres user with the same name. > > Deleting those two lines, and changing the manager.createContext() call to > > GSSContext secContext = manager.createContext(serverName, > desiredMechs[0], null, GSSContext.DEFAULT_LIFETIME); > > e.g. using a null for the 3rd argument > > makes the driver work fine. > > The javadoc for manager.createContext() says "Use null to act as the > default initiator principal.". > > So... > does that mean the two lines related clientCreds/Name aren't needed at all? > If they are needed for some scenarios, how can the code be modified to > handle both use cases? > > > thanks, > > Patrick > > > > > > -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc