Skip to content
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

Automatic IAM Authentication #345

Closed
withnale opened this issue May 16, 2023 · 12 comments
Closed

Automatic IAM Authentication #345

withnale opened this issue May 16, 2023 · 12 comments
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@withnale
Copy link

Feature Description

With the cloudsql-proxy the option exists for an automated IAM authenticated login when setting the auto-iam-authn command line option. (see https://github.com/GoogleCloudPlatform/cloud-sql-proxy)

With the most recent version of gcloud-cli it is possible now to create an IAM user using...

 gcloud alloydb users create USERNAME --type IAM_BASED

Would it now be possible to build in the automated IAM login logic, which I assume should be very similar to the implementation in cloudsql-proxy?

Sample code

No response

Alternatives Considered

No response

Additional Details

No response

@withnale withnale added the type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. label May 16, 2023
@jackwotherspoon
Copy link
Contributor

Hi @withnale! Thanks for raising a feature request on the AlloyDB Auth Proxy 😄

Yes, now that the AlloyDB Users API has launched into GA we should be able to at the very least start scoping out the work to add Automatic IAM database AuthN to the proxy.

AlloyDB IAM AuthN is still in Public Preview, it should be going GA later this quarter, we will probably want to wait until then before we integrate the feature into the proxy in case of any API or design changes.

We will provide updates on this bug and use it to track progress towards the feature.

Thanks for raising this feature request, have a great day! 😄

@jackwotherspoon jackwotherspoon added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label May 16, 2023
@enocom
Copy link
Member

enocom commented May 17, 2023

Quick clarification -- that's the REST API which is available right now, but currently Auto IAM AuthN isn't available. We can't comment on the roadmap, but will update here if there's any change to all that.

@withnale
Copy link
Author

On June 27th, it looks like the remaining backend functionality was enabled.

"IAM authentication for AlloyDB is available in Preview. You can add a role to Identity and Access Management (IAM) user or service accounts that lets them log into AlloyDB instances as database users."

@enocom
Copy link
Member

enocom commented Jun 29, 2023

Technically, that's manual IAM authentication. That means the caller has to provide the OAuth2 token as a password. That works fine for one-off connections, but when using connection pools, that works less well (e.g., the token expires after an hour and so the connection pool can't reconnect). In Cloud SQL, the Auto IAM AuthN feature is provided by the Proxy where it refreshes the OAuth2 token and provides it to the backend server. We don't have that yet here, but will update this thread when we have any news.

@withnale
Copy link
Author

I guess I need to look at the cloudsql-proxy implementation. I had assumed that the proxy was just maintaining the necessary valid token (like the manual flow) and replacing it into the conversations to cloudsql.

@enocom
Copy link
Member

enocom commented Jun 30, 2023

Yes, that's effectively correct. But the mechanism for transporting the token to the backend server uses the ephemeral certificate in Cloud SQL. Presently, there's no much mechanism for AlloyDB, but again, I'll update here when that changes. ;-)

@enocom enocom assigned enocom and unassigned jackwotherspoon Aug 21, 2023
@adamstrawson
Copy link

adamstrawson commented Sep 14, 2023

I understand that IAM authentication for AlloyDB is now in preview, is this unblocked from being able to be supported now?

(Source: https://cloud.google.com/alloydb/docs/manage-iam-authn)

@jackwotherspoon
Copy link
Contributor

@adamstrawson Yes it is now unblocked, the team is currently working on the change to support automatic IAM authentication. The work is being done with PR #423

@enocom
Copy link
Member

enocom commented Sep 14, 2023

@adamstrawson FWIW you can do the equivalent of Auto IAM Authentication on the direct path with either database/sql or pgx. If there's interest, I can show you how here.

@ssousa33
Copy link

ssousa33 commented Nov 8, 2023

@enocom , I would greatly appreciate seeing your example implementation

@enocom
Copy link
Member

enocom commented Nov 8, 2023

Here are some examples:

Lastly FWIW we're just about to ship this feature in the Go Connector and Proxy.

@enocom
Copy link
Member

enocom commented Nov 15, 2023

This is available now in v1.5.0 -- just pass the --auto-iam-authn flag.

@enocom enocom closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

5 participants