Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

OAuth Support on Postgres #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

srini09
Copy link

@srini09 srini09 commented Jan 10, 2023

No description provided.

@postgres-mirror
Copy link
Collaborator

Thanks for your Pull Request! 😄 This repo on GitHub is just a mirror of our real git repositories though, and can't really handle PRs. 😦 Hopefully you can redo the PR, and direct it to the git.postgresql.org repos? We have a developer guide, if that helps: https://wiki.postgresql.org/wiki/So,_you_want_to_be_a_developer%3F.

{
oauth_state state;
Port *port;
const char *discovery_uri;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to keep "issuer" here too. with discover_url optionally provided by the extension

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discovery_uri is provided by extension using the issuer (hba file) in the following manner:
appendStringInfo(&buf, "%s/.well-known/openid-configuration", port->hba->oauth_issuer);

oauth_exchange(void *opaq, const char *input, int inputlen,
char **output, int *outputlen, const char **logdetail)
{
char *p;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more descriptive name can be helpful here.

@@ -119,7 +119,7 @@ void
json_parse_manifest(JsonManifestParseContext *context, char *buffer,
size_t size)
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are changes to this file here intentional or accidental?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, json changes are required.

Comment on lines +24 to 28
#ifdef FRONTEND
#include "pqexpbuffer.h"
#else
#include "lib/stringinfo.h"
#include "miscadmin.h"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question. Are changes to this file intentional? Not clear why we need to change json manipulation for our change here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SASL exchange between client and server(for sending discovery_uri and scope) uses json object. Few changes are required for now( since it is on master branch). Will need to figure out the optimal changes.

"OAuth-Issuer", "", 40,
offsetof(struct pg_conn, oauth_issuer)},

{"oauth_client_id", NULL, NULL, NULL,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we remove those for now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. removed.

@@ -4034,6 +4067,12 @@ freePGconn(PGconn *conn)
free(conn->inBuffer);
free(conn->outBuffer);
free(conn->rowBuf);
free(conn->oauth_issuer);
free(conn->oauth_discovery_uri);
free(conn->oauth_client_id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is client_id and client_secret needed here? Since the token process is completely delegated to the client

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not required. Will remove this.

dutow added a commit to dutow/postgres that referenced this pull request Jan 7, 2025
Currently tupple iv calculatino is based only on the CTID, which
means that when postgres reuses the same address, it also reuses
the same IV. This makes our encryption theoretically weaker, in
case of some unlikely but not impossible attack scenarios.

As an improvement this commit also adds the command id into the
calculation. As the (ctid, cid) pair will be basically always
unique, this solves the problem.

Fixes postgres#112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants