Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WILT1-0000tK-Bu for pgsql-bugs@arkaria.postgresql.org; Tue, 25 Feb 2014 17:06:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WILT0-00071v-If for pgsql-bugs@arkaria.postgresql.org; Tue, 25 Feb 2014 17:06:50 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WILSv-0006uh-Q3 for pgsql-bugs@postgresql.org; Tue, 25 Feb 2014 17:06:45 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WILSs-00087A-0V for pgsql-bugs@postgresql.org; Tue, 25 Feb 2014 17:06:44 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 059855F7AA; Tue, 25 Feb 2014 12:07:38 -0500 (EST) Date: Tue, 25 Feb 2014 12:07:38 -0500 From: Stephen Frost To: Brian Crowell Cc: Tom Lane , pgsql-bugs Subject: Re: BUG #9337: SSPI/GSSAPI with mismatched user names Message-ID: <20140225170738.GA2921@tamriel.snowman.net> References: <7069.1393271901@sss.pgh.pa.us> <9531.1393275398@sss.pgh.pa.us> <10402.1393278034@sss.pgh.pa.us> <13625.1393288243@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wF2wSoFjAry8t1Dy" Content-Disposition: inline In-Reply-To: X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.8.0-35-generic (x86_64) X-Uptime: 10:10:24 up 26 days, 17:09, 7 users, load average: 0.00, 0.04, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org --wF2wSoFjAry8t1Dy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable * Brian Crowell (brian@fluggo.com) wrote: > On Mon, Feb 24, 2014 at 6:30 PM, Tom Lane wrote: > > Um. I spoke imprecisely, I see. The objection to involving a Kerberos > > server in determining the username is not solely about the cycles > > involved; it's that it requires identifying a specific Kerberos server > > to do it. Don't we lose multi-realm support if we have to know the > > server's password in advance of examining pg_hba.conf? >=20 > Not as far as I know. For GSSAPI, the server determines which password > to use based on the ticket, which includes the server's principal > name, and it looks it up in its own key file (PG's krb_server_keyfile > option). (For SSPI, I don't think you can use multiple passwords; if > coming from another domain, you'd need Active Directory's assistance > to cross the domain correctly.) There's two different things here- multi-realm (as in, a given server can live in multiple, independent, realms) and cross-realm (where the realms trust each other). For cross-realm, the server exists only in one realm and there's only one key for it; users from other realms will get a cross-realm ticket-granting-ticket which can then be used to request a service ticket for the server. For multi-realm, there's multiple keys because the server actually exists in multiple realms. I've not gone back to look at why we added multi-realm support, but I wonder if it might have specifically been to allow a PG server to be in both an AD realm and a Unix realm at the same time, without a cross realm trust between the two (which was problematic until AD got AES support since the only compatible encryption was quite weak). While I've seen discussion about it in the past, my recollection is that we *do* need to decide which entry in the keytab to use to decrypt the ticket first and to figure that out we need to know what we're going to use for krb_realm, krb_srvname and krb_server_hostname. Since those can be set in pg_hba.conf based on the information we're provided in the startup packet, we would be giving up some flexability in this case. =20 On the other hand, Magnus removing the krb5 auth method also removed krb_server_hostname.. I'll ask him about that because we should probably make that available under 'gss' or we may end up leaving some of our users out in the cold when 9.4 comes out and that'd be quite unfortuante. Regarding getting the username from the local credential cache, in the (recently removed) krb5 support, we were extracting the username in libpq from the credentials cache, but only needed it to pass back to the krb5 calls. Still, that is example code of how to do it using the Kerberos libraries, while you can use gss_inquire_cred() with GSSAPI. If we decide to allow an option where we use the 'default cred' in GSSAPI to also determine the PG username we are authenticating to, we'll want to think about how we support that in libpq and psql and consider what to do about the limitations of not being able to specify different krb_server_hostname depending on the user which is attempting to authenicate. > I also went back and checked, and the server does not have to contact > a Kerberos server to authenticate the client or determine its user > name. So long as the ticket is encrypted with the correct password > (Postgres's password), Postgres can decrypt it and know who the client > is and that they're really who they say they are. That's correct- a server in a Kerberos realm never directly communicates (as part of Kerberos) with the KDCs. > Since this request has turned out to be a little more complicated than > I thought, I'd like to volunteer to research it further and maybe > bring it along. It's not part of my job duties right now, so I'll have > to come back and visit it later, but so far I don't see anything > obvious that would make it unfeasible. The GSSAPI/Kerberos case looks > the easiest. SSPI/Negotiate will be harder because that requires > passing data back and forth; you couldn't finish in one packet. No complaints here, just a word of caution that we don't want to break existing setups and should consider what other systems do in this regard to avoid surprising behavior for users who are used to SSH or other Kerberos-enabled systems. Thanks, Stephen --wF2wSoFjAry8t1Dy Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBAgAGBQJTDM3aAAoJEO1sijiDR2RVAKwP/2PB/ptS32/4q5covjFoqwwU EQvj5cZ2LlakfEqeBEUPXbHQDi2Jg8dFQiIgOOU21xXPnDVm9mz7qJnrKy6Zgx6Y ug1BvoBohUOM8CWO7pze2WTBRZe3Kl0RG13V5J50sYvZKz1EQ6vcqbtHzhgeDu0+ qDaKrqkAQZIhIyHGBtoeR9SQza4apRstyRqiB2lgYO5d4Xh4KalcTL1waDWVMu4O kJowiw0STvm+D7r3C9MzNdxmAUWLoSD0WeiHJKlqtFwGUIof7VbW4GqvALWTzgCf He4ODBi8/TTmmn+JR9N5sHb1VvlH73xKPGJGTWxUoSQ8mouOOiudRdmlFVmMhFua 9ytKyU2Pnd0iEANUbCJvT5wLP5W3Eh9QV7MhZy3a2kIg2e1WSpjD5UrFFWWxKcUr 4V9ya/uM7ekjfJMxS6qczUHWfDldchnSdOJrpgg4znScsziXEO8bHTlNAkJMcIY2 iroJ0G1DQzl1LdP186zPz6mXnj4qbVpsiZPrdBGtsuCuQ/CMPGAHncx1wtS7hpj3 JTzJqo2xAr59HEKBKfXC0O5XdrJtCJ2hmYa8kvGOdZuoH7DPdJKJKEOd5vnQ6QLC Vh7mBQrEYUzFp8Ovh71zwNGEYTSyfRLYw8Kx4Q84TG1DiIbpUmhn2YgqeqRI1SV9 nfY62jGaKxUZigKIEmh4 =zJ11 -----END PGP SIGNATURE----- --wF2wSoFjAry8t1Dy--