Skip to content

Add username and password handling from user mapping#33

Merged
pashagolub merged 7 commits into
mainfrom
user_mapping
May 12, 2026
Merged

Add username and password handling from user mapping#33
pashagolub merged 7 commits into
mainfrom
user_mapping

Conversation

@Hunaid2000
Copy link
Copy Markdown
Contributor

User/password options are in server options which is not according to the standard. We retrieve username and password from user mapping instead of server options.

Those using this FDW need to enable auth, setup roles/users (like root) on etcd, as mentioned in docs. Then create a user mapping for that user with password like

CREATE USER MAPPING FOR CURRENT_USER SERVER my_etcd_server OPTIONS (user 'root', password 'secret');

@Hunaid2000 Hunaid2000 marked this pull request as ready for review January 28, 2026 10:57
@Hunaid2000 Hunaid2000 requested a review from pashagolub January 28, 2026 10:57
'root' is a special role, so no need to grant permissions to it.
Copy link
Copy Markdown
Contributor

@if-loop69420 if-loop69420 left a comment

Choose a reason for hiding this comment

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

Looks nice all in all. Good use of the pg_sys things even if they're unsafe, but there's no safe way to do it afaik. You've added tests and updated the docs, which I'm happy with. Please add the small change i suggested for the error message. Also sorry for taking so long to review

Comment thread src/lib.rs Outdated
@pashagolub
Copy link
Copy Markdown
Contributor

So..... Should we merge it?

@Hunaid2000
Copy link
Copy Markdown
Contributor Author

Hunaid2000 commented May 6, 2026

I believe it would be nice if before merging, we can test this branch for the internal project(s) using this extension?

Need to perform some initial steps.

Those using this FDW need to enable auth, setup roles/users (like root) on etcd, as mentioned in docs.

Something like:

etcdctl role add root
etcdctl user add etcd_user:secret
etcdctl user grant-role etcd_user root
etcdctl auth enable
-- After CREATE SERVER ...
CREATE USER MAPPING FOR CURRENT_USER SERVER my_etcd_server OPTIONS (user 'etcd_user', password 'secret');

@pashagolub
Copy link
Copy Markdown
Contributor

pashagolub commented May 6, 2026

etcdctl role add root

why do we need this line?

@Hunaid2000
Copy link
Copy Markdown
Contributor Author

Hunaid2000 commented May 7, 2026

root is special role with all permissions. We can create our own role, grant permissions to that role, and then grant that role to a user.

Or maybe, we can just create root user (which is also a special user) and use that. No need for role add line in that case.
etcdctl user add root:secret

I just wanted to give an example of creating a user other than root user.

EDIT: to enable auth, root user must be created first.

@pashagolub
Copy link
Copy Markdown
Contributor

Oh, so weird! :) Root is a special role but nevertheless it must be created! :) 🤯

Copy link
Copy Markdown
Contributor

@pashagolub pashagolub left a comment

Choose a reason for hiding this comment

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

Tested and approved!

@pashagolub pashagolub requested a review from if-loop69420 May 7, 2026 12:44
Copy link
Copy Markdown
Contributor

@if-loop69420 if-loop69420 left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks for adding the error message :)

@pashagolub pashagolub merged commit 1c1092b into main May 12, 2026
1 check passed
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