Thread: psycopg2 and java gssapi questions

psycopg2 and java gssapi questions

From
Mike Feld
Date:
Is it possible to authenticate with Postgres from a standalone application using gssapi? In other words, I am able to authenticate with Postgres when a human has logged in to either Windows or Linux and generated a ticket, but is it possible for say a Django site or Java application running on some server somewhere to authenticate with Postgres using gssapi? I realize that psycopg2 has a connection parameter for “krbsrvname”, but how does it generate a ticket? Is this the only alternative to secure authentication since Postgres does not support secure ldap (ldaps)?

Re: psycopg2 and java gssapi questions

From
basti
Date:
Hello,
have a look at

https://www.postgresql.org/docs/current/static/auth-methods.html

There are details about LDAP and GSSAPI.

On 20.12.2017 20:42, Mike Feld wrote:
> Is it possible to authenticate with Postgres from a standalone
> application using gssapi? In other words, I am able to authenticate with
> Postgres when a human has logged in to either Windows or Linux and
> generated a ticket, but is it possible for say a Django site or Java
> application running on some server somewhere to authenticate with
> Postgres using gssapi? I realize that psycopg2 has a connection
> parameter for “krbsrvname”, but how does it generate a ticket? Is this
> the only alternative to secure authentication since Postgres does not
> support secure ldap (ldaps)?


Re: psycopg2 and java gssapi questions

From
Mike Feld
Date:
This shows you how to setup GSSAPI authentication server side, which I have already done and have working. My question is from client side, without a human logged in to generate the ticket.
>>Hello,
>>have a look at

>>https://www.postgresql.org/docs/current/static/auth-methods.html

>>There are details about LDAP and GSSAPI.

>>On 20.12.2017 20:42, Mike F wrote:
>>> Is it possible to authenticate with Postgres from a standalone
>>> application using gssapi? In other words, I am able to authenticate with
>>> Postgres when a human has logged in to either Windows or Linux and
>>> generated a ticket, but is it possible for say a Django site or Java
>>> application running on some server somewhere to authenticate with
>>> Postgres using gssapi? I realize that psycopg2 has a connection
>>> parameter for “krbsrvname”, but how does it generate a ticket? Is this
>>> the only alternative to secure authentication since Postgres does not
>>> support secure ldap (ldaps)?

#AOLMsgPart_1.2_f53961cf-8686-4970-b4f8-52880410ff3e td{color: black;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;}.aolReplacedBody p.aolmail_MsoNormal,.aolReplacedBody li.aolmail_MsoNormal,.aolReplacedBody div.aolmail_MsoNormal {margin:0in; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman",serif;}.aolReplacedBody a:link,.aolReplacedBody span.aolmail_MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;}.aolReplacedBody a:visited,.aolReplacedBody span.aolmail_MsoHyperlinkFollowed {mso-style-priority:99; color:purple; text-decoration:underline;}.aolReplacedBody span.aolmail_hoenzb {mso-style-name:hoenzb;}.aolReplacedBody span.aolmail_EmailStyle18 {mso-style-type:personal; font-family:"Calibri",sans-serif; color:#1F497D;}.aolReplacedBody span.aolmail_EmailStyle19 {mso-style-type:personal-reply; font-family:"Calibri",sans-serif; color:#1F497D;}.aolReplacedBody .aolmail_MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;}@page WordSection1 {size:8.5in 11.0in; margin:1.0in 1.0in 1.0in 1.0in;}.aolReplacedBody div.aolmail_WordSection1 {page:WordSection1;}

Re: psycopg2 and java gssapi questions

From
Achilleas Mantzios
Date:
On 20/12/2017 21:42, Mike Feld wrote:
Is this the only alternative to secure authentication since Postgres does not support secure ldap (ldaps)?

Have you checked out : ldaptls parameter ? https://www.postgresql.org/docs/10/static/auth-methods.html#AUTH-LDAP

-- 
Achilleas Mantzios
IT DEV Lead
IT DEPT
Dynacom Tankers Mgmt

Re: psycopg2 and java gssapi questions

From
Magnus Hagander
Date:


On Wed, Dec 20, 2017 at 8:42 PM, Mike Feld <m1f7@aol.com> wrote:
Is it possible to authenticate with Postgres from a standalone application using gssapi? In other words, I am able to authenticate with Postgres when a human has logged in to either Windows or Linux and generated a ticket, but is it possible for say a Django site or Java application running on some server somewhere to authenticate with Postgres using gssapi? I realize that psycopg2 has a connection parameter for “krbsrvname”, but how does it generate a ticket? Is this the only alternative to secure authentication since Postgres does not support secure ldap (ldaps)?

Sure it is. 

libpq won't generate the initial ticket, though. The way to do it is to have your django or whatever application run "kinit" for the user before it starts. This will request a TGT, and the ticket will be present in that users environment, and will be used by the libpq client. (it might look slightly different for a Java client, but the principle is the same)

--

Re: psycopg2 and java gssapi questions

From
Dave Cramer
Date:
On 21 December 2017 at 05:27, Magnus Hagander <magnus@hagander.net> wrote:


On Wed, Dec 20, 2017 at 8:42 PM, Mike Feld <m1f7@aol.com> wrote:
Is it possible to authenticate with Postgres from a standalone application using gssapi? In other words, I am able to authenticate with Postgres when a human has logged in to either Windows or Linux and generated a ticket, but is it possible for say a Django site or Java application running on some server somewhere to authenticate with Postgres using gssapi? I realize that psycopg2 has a connection parameter for “krbsrvname”, but how does it generate a ticket? Is this the only alternative to secure authentication since Postgres does not support secure ldap (ldaps)?

Sure it is. 

libpq won't generate the initial ticket, though. The way to do it is to have your django or whatever application run "kinit" for the user before it starts. This will request a TGT, and the ticket will be present in that users environment, and will be used by the libpq client. (it might look slightly different for a Java client, but the principle is the same)





Re: psycopg2 and java gssapi questions

From
Stephen Frost
Date:
Magnus, Mike,

* Magnus Hagander (magnus@hagander.net) wrote:
> On Wed, Dec 20, 2017 at 8:42 PM, Mike Feld <m1f7@aol.com> wrote:
>
> > Is it possible to authenticate with Postgres from a standalone application
> > using gssapi? In other words, I am able to authenticate with Postgres when
> > a human has logged in to either Windows or Linux and generated a ticket,
> > but is it possible for say a Django site or Java application running on
> > some server somewhere to authenticate with Postgres using gssapi? I realize
> > that psycopg2 has a connection parameter for “krbsrvname”, but how does it
> > generate a ticket? Is this the only alternative to secure authentication
> > since Postgres does not support secure ldap (ldaps)?
>
> Sure it is.

Yup.

> libpq won't generate the initial ticket, though. The way to do it is to
> have your django or whatever application run "kinit" for the user before it
> starts. This will request a TGT, and the ticket will be present in that
> users environment, and will be used by the libpq client. (it might look
> slightly different for a Java client, but the principle is the same)

You would actually want to use a keytab and then kstart/k5start to make
sure that you've always got a valid ticket.  Just doing a kinit would
mean that the TGT will eventually expire and cause connections to fail.

Thanks!

Stephen

Attachment