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

(A single, complete) Cloud Client Library for IAM #11572

Open
rrrix opened this issue May 3, 2022 · 6 comments
Open

(A single, complete) Cloud Client Library for IAM #11572

rrrix opened this issue May 3, 2022 · 6 comments
Assignees
Labels
api: iam Issues related to the Identity and Access Management API. next major: breaking change this is a change that we should wait to bundle into the next major version type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@rrrix
Copy link

rrrix commented May 3, 2022

I'm cross-posting this from googleapis/google-cloud-python #10643, because it's not clear where's actually supposed to go...


Hi Googlers,

I'm requesting the Identity and Access Management IAM API (e.g. https://iam.googleapis.com) be added as a supported Python Cloud Client Library.

I believe it is both reasonable and expected for the existing Identity and Access Management (python-iam) package fully support all IAM APIs. That was my first place to look for working with IAM Roles, Permissions, and Service Accounts. I thought my brain was having a short circuit and that I made a mistake when I saw what is really only the Service Account Credentials API (e.g. https://iamcredentials.googleapis.com).

As far as code generation goes, googleapis/googleapis has full and complete definitions for all IAM APIs:

  • iam/admin/v1/iam.proto
    • Endpoint: iam.googleapis.com
    • All Standard Methods (List, Get, Create, Update, Delete) for All admin/v1 Resources (Service Accounts, Service Account Keys, Roles, Permissions)
    • All Custom Methods (TestIamPermissions, QueryGrantableRoles, QueryTestablePermissions, QueryAuditableServices, LintPolicy)
  • iam/credentials/v1/iamcredentials.proto
    • This is currently the only API that is already in the python-iam package.
    • Endpoint: iamcredentials.googleapis.com
    • All Methods: GenerateAccessToken, GenerateIdToken, SignBlob, SignJwt
  • iam/v1/iam_policy.proto
    • Endpoint: iam-meta-api.googleapis.com
    • All Standard Methods (SetIamPolicy, GetIamPolicy, TestIamPermissions)
    • Requires iam/v1/policy.proto
  • iam/v1beta/workload_identity_pool.proto
    • Endpoint: iam.googleapis.com
    • All Standard Methods (List, Get, Create, Update, Delete) for v1beta Workload Identity Pools
  • iam/v2beta/policy.proto and iam/v2beta/deny.proto
    • Endpoint: iam.googleapis.com
    • The new and very awesome v2beta IAM Policies API
    • CRUDL for IAM Policies
    • Includes the new Deny policies API

I was a little surprised to find IAM does not have complete support in the Python Cloud Client Libraries. Seems like an oversight? I mean... You can't really do Google Cloud without IAM... :)

Also, it might be worth looking at how the current "IAM" libraries are named / described, since it's very confusing unless you take a few hours to read through all of the code and documentation for each of the packages (as I did).

To be honest, it was a poor developer/user experience constantly being directed to use Client Libraries that don't exist.

Currently, Python Cloud Client Libraries lists two different versions of "Identity and Access Management" packages, one "IAM Logging Protos" package and one "IAM Policy Troubleshooter API" package listed in the README:

I'm not sure why the first two are both called "Identity and Access Management" when neither of them are full IAM APIs. The "IAM Logging Protos" is the only library appropriately named for its specific limited subset of IAM functionality.

The python-grpc-google-iam-v1 package is even more mysterious, as it a single subdirectory (iam/v1/) which appears to be generated or copied from the googleapis/google/iam interface definitions. 🤔

I hope we can get a nice idiomatic & Pythonic Google Cloud IAM SDK at some point. Thanks in advance!

@product-auto-label product-auto-label bot added the api: iam Issues related to the Identity and Access Management API. label May 3, 2022
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label May 4, 2022
@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. and removed triage me I really want to be triaged. labels May 5, 2022
@parthea
Copy link
Contributor

parthea commented May 5, 2022

Thanks for the feedback @rrrix! This is definitely something that needs to be fixed. I'll investigate if it's possible to make improvements in a non-breaking way. I've labeled this as a bug and added it to our internal backlog.

@simon-anz
Copy link

simon-anz commented May 18, 2022

100% agree, and had the same experience. It seems like a strange omission to not have nice APIs for IAM, and have to use the old-style dynamic client (ugh). Things like listing roles, etc

Compare the service approach which returns typeless dict:

    creds, _ = google.auth.default()
    service = discovery.build('iam', 'v1', credentials=creds)
    request = service.roles().list(view='FULL')

Vs below (example) which returns nicely typed structure

    res = asset_v1.AssetServiceClient(credentials=creds).search_all_iam_policies(scope=scope, query=query)

@alsyia
Copy link

alsyia commented Oct 4, 2022

Any update on this? What's the preferred way to, for example, get the list of all service accounts?

@andrew-kline
Copy link

Any update on this? What's the preferred way to, for example, get the list of all service accounts?

AFAIK the only way is to use the API wrapper client and build the service through it (here is the example: https://cloud.google.com/iam/docs/reference/rest/v1/projects.serviceAccounts/list).

I have to double down on my support for this - particularly for this service, but also for others (DNS, for example). IAM is a foundational aspect of writing applications that interact with GCP and I feel like I spend 90% of my time trying to decipher and compare what's available to me between the client libraries and the APIs.

@alsyia
Copy link

alsyia commented Dec 7, 2022

Any update on this? What's the preferred way to, for example, get the list of all service accounts?

AFAIK the only way is to use the API wrapper client and build the service through it (here is the example: https://cloud.google.com/iam/docs/reference/rest/v1/projects.serviceAccounts/list).

I have to double down on my support for this - particularly for this service, but also for others (DNS, for example). IAM is a foundational aspect of writing applications that interact with GCP and I feel like I spend 90% of my time trying to decipher and compare what's available to me between the client libraries and the APIs.

Thanks for the answer! That's indeed what I ended up doing.

+1 for a proper IAM support...

@parthea
Copy link
Contributor

parthea commented Aug 14, 2023

I'm going to transfer this issue to the google-cloud-python repository. The code in this repository will be migrated there within the next few weeks.

@parthea parthea transferred this issue from googleapis/python-iam Aug 14, 2023
@parthea parthea added next major: breaking change this is a change that we should wait to bundle into the next major version type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: iam Issues related to the Identity and Access Management API. next major: breaking change this is a change that we should wait to bundle into the next major version type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

7 participants
@rrrix @alsyia @parthea @yoshi-automation @andrew-kline @simon-anz and others