Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1obGub-0001CL-Ed for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Sep 2022 07:46:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1obGua-00057W-Db for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Sep 2022 07:46:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ob7vl-0002vZ-Se for pgsql-hackers@lists.postgresql.org; Wed, 21 Sep 2022 22:10:58 +0000 Received: from mail-cusazon11020015.outbound.protection.outlook.com ([52.101.61.15] helo=na01-obe.outbound.protection.outlook.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ob7ve-0006TT-Jg for pgsql-hackers@postgresql.org; Wed, 21 Sep 2022 22:10:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kGC1GN7tqCW9F/cFd3GyJmWAl70myap7dcy8l71Cc8aAyaXXnDoeAgGHFzkAw7sHZoDm1tCCE2yungb8k0fRwIoSYDpUi5Ng3eVSujgzV2CvHyjvAClJSoQWNUVHvSzOaNgwlbP9Ez+/wD3fJWv8mbIOJhLN5ocWDX+QBgSE/BpmzU/ecSK42HsUGb9r0BaD6RKr1ZeXSYccyg/NhlV40afeYFwxniLKFh0nl21phsZI2OF8xxkf0a5zIJcS/MIl+/mSnVSg9y8EdbeeM0mzfQqJaZc+ahNllAFbN4VW4HwhL20m136SLL3FRDlyYLAAHJ2egdMn/qlayMqTwqxUnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=U9O0YLnpcLVhT1PW5u3OuHQ0OLZlty7lTtKfBoPhO9g=; b=FQM9mYQEwW2kRIhXD2KH9QBbX1d2EiaHR4pQC877+AdTiCjI0ptLADsDkpydgrtJ9Lx8IYQF6Y/hUMZcND75/A7CddYxup9Xv8f34F6KsaGJoQFYfwGtaKOlIw9aQhZIyZUwWgElnm49CFiFEw9eub64O3M13tGqx52cqwICwmSGBQG4Nog4t9S6ZovOkFZpAVzQwFSuyeGRkY/LbgkdNZi9PwQkXFcp9QytaxZcvUf/dgt76zrHDacHd1SXbHIKQpTRxDMAVvGBYVXiarQY06mSpDzimiU/HYpekzktEHpKYOkMXn49Tr2WKlLF4Gg3xXt8sB813yYzOvAN59XPtA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=U9O0YLnpcLVhT1PW5u3OuHQ0OLZlty7lTtKfBoPhO9g=; b=UbVxiBg3L/d1174otSeBwak1PEj/zWBY3s16gNkHVmlIFgqv7LHGPnFLJYvdgM2tnmv+Ql56sGk5Mr1uvCuDTU/clsW4Sv7NYifgo+Ch96g2A40f7JVF0wnhgOkz0jrn6k1KhQHNNC2h6Q2wdhw0mnT/fCvby44LuE2wAj6THtQ= Received: from MN0PR21MB3169.namprd21.prod.outlook.com (2603:10b6:208:379::10) by BYAPR21MB1349.namprd21.prod.outlook.com (2603:10b6:a03:115::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.7; Wed, 21 Sep 2022 22:10:25 +0000 Received: from MN0PR21MB3169.namprd21.prod.outlook.com ([fe80::abb4:4fe4:59b6:73ae]) by MN0PR21MB3169.namprd21.prod.outlook.com ([fe80::abb4:4fe4:59b6:73ae%3]) with mapi id 15.20.5676.006; Wed, 21 Sep 2022 22:10:25 +0000 From: Andrey Chudnovskiy To: Jacob Champion , mahendrakar s CC: "pgsql-hackers@postgresql.org" , "smilingsamay@gmail.com" , "andres@anarazel.de" , Mahendrakar Srinivasarao Subject: RE: [EXTERNAL] Re: [PoC] Federated Authn/z with OAUTHBEARER Thread-Topic: [EXTERNAL] Re: [PoC] Federated Authn/z with OAUTHBEARER Thread-Index: AQHYzK5Qv3O2da3q3kaTP3NyRDt1m63o9YOAgAEYeACAAFiTcA== Date: Wed, 21 Sep 2022 22:10:25 +0000 Message-ID: References: <2f06a4aef1d5defe4b7aaec01478572e5557d32a.camel@vmware.com> <8a5a35b31c3f25f6b047e77def0445a60399981d.camel@vmware.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=4df332d6-b80c-45c9-bb5f-340b28856cea;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ContentBits=0;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=true;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Method=Standard;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=Internal;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2022-09-21T21:20:22Z;MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: MN0PR21MB3169:EE_|BYAPR21MB1349:EE_ x-ms-office365-filtering-correlation-id: ea8d49c1-a9e5-44d7-6cfe-08da9c1e15a6 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: C7/q9sup00kA0CnRk+UeNzA3QpB9FXIXAY7eDx5a6HJixp6dnkpR1FKjbAk2/kMg9tp56+ZJUh3b55wKp31idEcCWhYzpQLejcq7BAqxEB7VS5M1jqlqMgADywPJCSzExryuKYBXYg4bH+M5Xuhe+jSTPBHjvD6jnYQTmACNu61HRlZz9x1J0aUbr7DuENniXV0/bNL0yzA0pNsXq65UbAhwkk5CCVbIiVscqYx4GFZ4AZZWNTBQ/H9q1P5mj7cKae3WMMF0lnu3+86i0kpEmDX7ZKtoSsMgqSPtCKO37g2hWBLZzyMDLv6vgOWwoY1JgYtECB6X8X7Lu2PV0sw4jBnelZLEAk0HoZBx1D+HE998BtKxfG2VuctRIbbtbtFrfUEApaN3xIIjHQsCFRw3cOeBmWHE+M9J68YMFwu0Xo9Tc3tLdTUOdbxDFvxrMvtyTWOgGNE60mIN/cRIOMQv4iSehJjrPAv+CL7FSrvW0/1Tiagie7EDeEOx04cxnO9iz2q1GCAmCmTTTt8kbB+sM8FLWERQqk15JDS+QrnaoJxSkE0kb8507nUKtxT0uATIrhVFp6+asI5vnmBaP9V6ST43cWg6Eo+W0m+6G/0u6r2ohazWOMAl1Z+dqCyyoG3FhbQUCcNNdHjvFaWhqjMgu7N6L5AZsE/XiMxkvIjTiimy3vDIB83iTdWzLC+cDYclY5tu1tDoTGsa/rn1k5/vUHtIby3/uf+J9ot0MGAcVgaBbczYFvMVt5M3hJVPeCNg/V2lPRItJDfAOVkhAgyGDhTqox+BrcU7UJjGDjP4kZ8VrqpsFeo23Lvn8f0Pm0XC x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MN0PR21MB3169.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(39860400002)(366004)(346002)(396003)(451199015)(9686003)(186003)(107886003)(71200400001)(6506007)(7696005)(53546011)(2906002)(26005)(8990500004)(83380400001)(5660300002)(52536014)(66946007)(55016003)(10290500003)(478600001)(110136005)(54906003)(4326008)(66446008)(66556008)(66476007)(76116006)(41300700001)(316002)(8676002)(966005)(64756008)(8936002)(82950400001)(82960400001)(33656002)(86362001)(38070700005)(122000001)(38100700002);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?RkKqNEO1ItTwlPLLRh+yhqubT1PEUBBO2gWZGqEI/aAR17JKteaIg3/QAbmT?= =?us-ascii?Q?1ij5yBVY0tZkvAegQrWLa3Cgk9kcXN3gTJvOatc0RLb6476n+iCYspVNB4Zt?= =?us-ascii?Q?UDcelvj4GN5opnHZFEqpZUktcHawu5bjSmFErKdKtk8yy8aIkdXklt2bIYEr?= =?us-ascii?Q?92uyUuYWex+dKnwWn5W7gJvvdxY18b6LApOfO6N+Z/rU9H5yq7EISDESaad5?= =?us-ascii?Q?Lcx3zoU3MMFlkq7mVZZvE2TNTQTEEGojRP7GoUmlR4WGp4cgmCf/rl85RMQ8?= =?us-ascii?Q?mvFHgiGxDhwH76xkLQ7cvsPuu3tTJcUczeth3bmGTq9TVz+qFAHGiu741eK5?= =?us-ascii?Q?MZdrITvwyo5S4A4BHfTnFpA+0e9RECS1CV4uf1G/kOEXYwzwmixyBwqw/Or4?= =?us-ascii?Q?TZ4a5czyyi+/VJ9nrHfDojLVxexiQMuzhnpZwW/Yc3IW1T66GngD/g5VEnkP?= =?us-ascii?Q?NALk9PkHcQyc1R1V1HVUPVPMHYN6YoTS3ZW0ndvzh2uxB4wnQKeoOHaUqznB?= =?us-ascii?Q?S7azk4+QsHIf02NbsVPQEnB1P/TskjuPtfq/Gp6jlY8wzhTw06gvq0pHNJCB?= =?us-ascii?Q?RP/CriOtn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97?= =?us-ascii?Q?CFnwUq+2Qsk7FSDZXukFGEP2LokLf8Ak/2Tt?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: MN0PR21MB3169.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ea8d49c1-a9e5-44d7-6cfe-08da9c1e15a6 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2022 22:10:25.2371 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aN1XRiz33qsUtPDFqYY5nrdqKVOTOXwQhPw4ssdWoT9rjnf3GY7baNK1pMU1gk4/MFPItc743OZzv3duXPXGUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR21MB1349 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk We can support both passing the token from an upstream client and libpq imp= lementing OAUTH2 protocol to obtaining one. Libpq implementing OAUTHBEARER is needed for community/3rd party tools to h= ave user-friendly authentication experience: 1. For community client tools, like pg_admin, psql etc.=20 Example experience: pg_admin would be able to open a popup dialog to aut= henticate customer and keep refresh token to avoid asking the user frequent= ly. 2. For 3rd party connectors supporting generic OAUTH with any provider. Use= ful for datawiz clients, like Tableau or ETL tools. Those can support both = user and client OAUTH flows. Libpq passing toked directly from an upstream client is useful in other sce= narios: 1. Enterprise clients, built with .Net / Java and using provider-specific a= uthentication libraries, like MSAL for AAD. Those can also support more adv= ance provider-specific token acquisition flows. 2. Resource-tight (like IoT) clients. Those can be compiled without optiona= l libpq flag not including the iddawc or other dependency. Thanks! Andrey. -----Original Message----- From: Jacob Champion =20 Sent: Wednesday, September 21, 2022 9:03 AM To: mahendrakar s Cc: pgsql-hackers@postgresql.org; smilingsamay@gmail.com; andres@anarazel.d= e; Andrey Chudnovskiy ; Mahendrakar Srini= vasarao Subject: [EXTERNAL] Re: [PoC] Federated Authn/z with OAUTHBEARER [You don't often get email from jchampion@timescale.com. Learn why this is = important at https://aka.ms/LearnAboutSenderIdentification ] On Tue, Sep 20, 2022 at 4:19 PM Jacob Champion wr= ote: > > 2. Add support to pass on the OAuth bearer token. In this > > obtaining the bearer token is left to 3rd party application or user. > > > > ./psql -U -d 'dbname=3Dpostgres=20 > > oauth_client_id=3D oauth_bearer_token=3D > > This hurts, but I think people are definitely going to ask for it,=20 > given the frightening practice of copy-pasting these (incredibly=20 > sensitive > secret) tokens all over the place... After some further thought -- in this case, you already have an opaque Bear= er token (and therefore you already know, out of band, which provider needs= to be used), you're willing to copy-paste it from whatever service you got= it from, and you have an extension plugged into Postgres on the backend th= at verifies this Bearer blob using some procedure that Postgres knows nothi= ng about. Why do you need the OAUTHBEARER mechanism logic at that point? Isn't that i= dentical to a custom password scheme? It seems like that could be handled c= ompletely by Samay's pluggable auth proposal. --Jacob