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 support for new ComputeResourceAuthenticator #123

Merged
merged 18 commits into from
Jul 26, 2021

Conversation

padamstx
Copy link
Member

@padamstx padamstx commented Jul 20, 2021

This PR introduces support for a new authenticator implementation which supports the "Compute Resource Identities" feature.

@padamstx padamstx marked this pull request as ready for review July 21, 2021 00:43
@padamstx padamstx requested review from dpopp07, pyrooka and rmkeezer July 21, 2021 00:44
@padamstx padamstx self-assigned this Jul 21, 2021
Copy link
Member

@pyrooka pyrooka 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 to me!

)

// CriAuthenticator retrieves a "compute resource token" from the local compute resource (VM)
// and uses that to obtain an IAM access token by invoking the IAM "get token" operation w/grant-type=cr-token.
Copy link
Member

Choose a reason for hiding this comment

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

Typo?

Suggested change
// and uses that to obtain an IAM access token by invoking the IAM "get token" operation w/grant-type=cr-token.
// and uses that to obtain an IAM access token by invoking the IAM "get token" operation with grant-type=cr-token.

Copy link
Member Author

Choose a reason for hiding this comment

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

it wasn't really a typo as "w/xyz" typically means "with xyz", but I changed it to be clear :)

Copy link
Member

Choose a reason for hiding this comment

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

I know, I just thought it wasn't intentional, sorry!

Copy link
Member Author

Choose a reason for hiding this comment

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

no worries :)

@padamstx
Copy link
Member Author

Reviewers,
I've updated this PR to reflect all the changes that were made to the design yesterday (except for one).
This includes:

  1. The authenticator itself was renamed to be ComputeResourceAuthenticator and this includes changes to the ctors, etc.
  2. The auth type string was changed from cri to crauth
  3. The various references to cri within the code were changes to be cra (short for Compute Resource Authenticator).
  4. The external config property name for the cr token file was changed from CRTOKEN_FILENAME to CR_TOKEN_FILENAME.

I still need to update Authentication.md and will do that as part of this PR before merging :)

@padamstx padamstx requested a review from pyrooka July 22, 2021 21:00
@padamstx padamstx force-pushed the cri-authenticator branch 3 times, most recently from 8ef56e3 to 967ab89 Compare July 25, 2021 19:25
@padamstx
Copy link
Member Author

I've updated the go core's Authentication.md file to include info about the new ComputeResourceAuthenticator, plus a few editorial changes in the other sections as well.
This PR is ready for review.

@padamstx padamstx changed the title feat: add support for new CRI authenticator feat: add support for new ComputeResourceAuthenticator Jul 26, 2021
Copy link
Member

@dpopp07 dpopp07 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! 👍

authType := properties[PROPNAME_AUTH_TYPE]
if authType == "" {
authType = AUTHTYPE_IAM
// If the APIKEY property is specified, then we'll guess IAM... otherwise CRI.
Copy link
Member

Choose a reason for hiding this comment

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

I know this is an internal comment, so not a big deal, but if we're not using "CRI" terminology anymore we may want to change this

// crToken := authenticator.retrieveCRToken()
// if crToken == "" {
// return fmt.Errorf(ERRORMSG_UNABLE_RETRIEVE_CRTOKEN)
// }
Copy link
Member

Choose a reason for hiding this comment

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

I think I agree with moving this to the RequestToken method since validation only happens once and the state could theoretically change over time. I don't really think we need to verify that we can get a token until it's time to get a token. I would be in favor of removing these comments so as not to clutter the code moving forward

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I actually intended to remove that but forgot :)

@padamstx padamstx removed the request for review from rmkeezer July 26, 2021 20:15
@padamstx padamstx merged commit c7631e3 into main Jul 26, 2021
@padamstx padamstx deleted the cri-authenticator branch July 26, 2021 20:26
ibm-devx-sdk pushed a commit that referenced this pull request Jul 26, 2021
# [5.6.0](v5.5.1...v5.6.0) (2021-07-26)

### Features

* add support for new ComputeResourceAuthenticator ([#123](#123)) ([c7631e3](c7631e3))
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 5.6.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀


// Check to make sure that one of IAMProfileName or IAMProfileID are specified.
if authenticator.IAMProfileName == "" && authenticator.IAMProfileID == "" {
return fmt.Errorf(ERRORMSG_EXCLUSIVE_PROPS_ERROR, "IAMProfileName", "IAMProfileID")
Copy link
Member

Choose a reason for hiding this comment

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

@padamstx I was reading through this while working on my implementation and I noticed a small detail that I didn't pick up on in my review - I don't think this is the right error message for this situation. The IAM Profile name and ID can both be specified, right? But this error message says that exactly one must be specified

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, you're right... As I recall, I consciously used this pre-existing error message (rather than create a new one) for the case where neither of the properties are specified. Technically it's not 100% correct because, as you say, they can in fact be specified together (as long as they are consistent with each other).
I can open an issue to fix this by introducing a new error message that covers this case.

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

Successfully merging this pull request may close these issues.

4 participants