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

feat: add ImpersonatedServiceAccountCredentials #421

Merged

Conversation

PsyonixMonroe
Copy link
Contributor

In order to add support for IAM Blob Signing via API request in google-cloud-php-iam-credentials, there needs to be a way to extend the different types of credential loaders that are supported by this lower level library. Support cannot be added here directly due to the introduction of a circular dependancy.

This change will allow higher level libraries to "register" custom Credentials Loader Factory Method objects and have them considered when processing application_default_credentials.json
(impersonated_service_account as an example).

@PsyonixMonroe PsyonixMonroe requested a review from a team as a code owner October 6, 2022 00:00
@PsyonixMonroe PsyonixMonroe force-pushed the feature/credentials_loader_extension branch from de40edb to 120bcda Compare October 6, 2022 00:01
Copy link
Contributor

@dwsupplee dwsupplee left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @PsyonixMonroe :).

It turns out we have the ability to sign a blob with IAM in this library as is, so we should be able to utilize that, it can be found here: https://github.com/googleapis/google-auth-library-php/blob/main/src/Iam.php#L65

See GCECredentials as an example of how the implementation is used.

Would you be open to migrating ImpersonatedServiceAccountCredentials into the credentials directory in this repo so it can be used more widely?

@PsyonixMonroe PsyonixMonroe force-pushed the feature/credentials_loader_extension branch from 120bcda to 1f24c4c Compare October 19, 2022 19:49
@PsyonixMonroe PsyonixMonroe changed the title Add Custom Credentials Loader support Add Impersonated Service Account Credentials Holder for Blob Signing Oct 19, 2022
@PsyonixMonroe
Copy link
Contributor Author

@dwsupplee Thanks for the feedback!

I didn't know that IAM signing was already supported at this level. I have update the PR to add ImpersonatedServiceAccountCredentials in this library.

I also migrated the signBlob method from GCECredentials into a trait so that it can be shared with ISAC in the same way that ServiceAccountSignerTrait shares signBlob between ServiceAccountCredentials and ServiceAccountJwtAccessCredentials.

The nice thing is that with this change there won't need to be a second one in cloud-core.

Please let me know if there is any other feedback.

Copy link
Contributor

@bshaffer bshaffer left a comment

Choose a reason for hiding this comment

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

Really great stuff! This is super close, and I've added mostly nits with one major change that is kinda itself a nit (but it's a paradigm used by other languages that I prefer - maintaining a "source credential" instead of using inheritance)

src/Credentials/GCECredentials.php Outdated Show resolved Hide resolved
src/Credentials/ImpersonatedServiceAccountCredentials.php Outdated Show resolved Hide resolved
src/Credentials/ImpersonatedServiceAccountCredentials.php Outdated Show resolved Hide resolved
src/Credentials/ImpersonatedServiceAccountCredentials.php Outdated Show resolved Hide resolved
src/Credentials/ImpersonatedServiceAccountCredentials.php Outdated Show resolved Hide resolved
Copy link
Contributor

@dwsupplee dwsupplee left a comment

Choose a reason for hiding this comment

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

This is greatly appreciated, thank you @PsyonixMonroe. Just a few notes from me, otherwise looks really great. I think this will help close out #387 for us as well.

src/IAMSignerTrait.php Outdated Show resolved Hide resolved
src/IAMSignerTrait.php Outdated Show resolved Hide resolved
Copy link
Contributor

@dwsupplee dwsupplee left a comment

Choose a reason for hiding this comment

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

Just a small nit on the licenses. It looks like we may also need you to sign the CLA, please see here for more: https://cla.developers.google.com/

src/Credentials/ImpersonatedServiceAccountCredentials.php Outdated Show resolved Hide resolved
src/IamSignerTrait.php Outdated Show resolved Hide resolved
@dwsupplee
Copy link
Contributor

It looks like there are a few style / static analysis issues as well: https://github.com/googleapis/google-auth-library-php/actions/runs/3340256021/jobs/5619317746

@PsyonixMonroe
Copy link
Contributor Author

I'm currently working with the owner of the Group that controls the CLA list for Epic. Its just taking me a bit of time track it down.

This will refactor the current GCECredentials method for calling IAM to
perform request signing into a trait that can be shared with other
CredentialLoaders that need to call IAM.

Adds ImpersonatedServiceAccountCredentials which uses the new trait to
perform blob signing through IAM, but does so when impersonating a
service account with `gcloud auth application-default login
--impersonate-service-account=<account name>`
@PsyonixMonroe PsyonixMonroe force-pushed the feature/credentials_loader_extension branch 3 times, most recently from 21cd618 to 8353e6b Compare November 3, 2022 18:14
@PsyonixMonroe
Copy link
Contributor Author

PsyonixMonroe commented Nov 3, 2022

It appears that this most recent PHPStan failure is for a file not modified by this PR.

@dwsupplee
Copy link
Contributor

@PsyonixMonroe good call out. It looks like we can safely ignore that for this PR.

Once we get the CLA signed and @bshaffer's sign off on his requested changes we should be good to go here. Thanks again for the great PR.

@dwsupplee
Copy link
Contributor

@PsyonixMonroe have you had any luck with the CLA progress? Please let us know if there's anything we can do to help.

@PsyonixMonroe
Copy link
Contributor Author

@dwsupplee I've been getting the occasional check in from my Epic Point of Contact on the CLA, it appears that at some point in the last year our CLA group was removed(?deleted?) and they are trying to get it recreated.

Not sure if there is anything from your side that can be done about getting this set back up. It seems like we are currently working on getting a new CLA in place and the group recreated.

@bshaffer
Copy link
Contributor

bshaffer commented Nov 15, 2022

@PsyonixMonroe I don't know anything about the CLA group you're referring to, but the bot simply checks that the email used to make the github commit (matt.monroe@psyonix.com) has signed the CLA, which can be done here: https://cla.developers.google.com/

So I suggest you simply go to the above URL and sign the CLA yourself, and that should do the trick.

See the failing check for more information.

@PsyonixMonroe
Copy link
Contributor Author

@bshaffer Since this is being done as part of my work for Psyonix (owned by Epic Games), I need Epic to go through the Company CLA process, not the individual.

@bshaffer
Copy link
Contributor

bshaffer commented Nov 15, 2022

@bshaffer Since this is being done as part of my work for Psyonix (owned by Epic Games), I need Epic to go through the Company CLA process, not the individual

Sounds good. If there is any "approved GitHub email" with your company which has signed it, alternatively they could commit the changes and submit a new PR and we could merge that.

@PsyonixMonroe
Copy link
Contributor Author

@bshaffer Looks like the CLA check is passing now 🥳

@bshaffer bshaffer changed the title Add Impersonated Service Account Credentials Holder for Blob Signing feat: add ImpersonatedServiceAccountCredentials Nov 23, 2022
@bshaffer bshaffer merged commit de766e9 into googleapis:main Nov 28, 2022
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.

None yet

3 participants