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

(PF-2437) Allow r10k to authenticate to the Forge #1192

Merged
merged 1 commit into from
Aug 30, 2021

Conversation

binford2k
Copy link
Contributor

In the near future, the Forge will be adding support for authenticated
module downloads. This extends support for token based authentication to
that use case.

@binford2k binford2k requested a review from a team July 28, 2021 17:51
@binford2k binford2k force-pushed the support_forge_auth branch from 91dad73 to 565dafc Compare July 28, 2021 17:54
@Magisus
Copy link
Collaborator

Magisus commented Jul 28, 2021

Oh cool, good timing on us adding this support then.

Copy link
Contributor

@mwaggett mwaggett left a comment

Choose a reason for hiding this comment

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

Have you done any manual testing?

Is there Forge work that needs to land before this can be released?

custom Forge server. When set, 'baseurl' must also be set.
You will need to prepend your token with 'Bearer ' if using Artifactory as your Forge server.
The 'authorization_token' setting allows you to provide a token for authenticating to a Forge server.
You will need to prepend your token with 'Bearer ' to authenticate to the Forge or when using your own Artifactory server.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You will need to prepend your token with 'Bearer ' to authenticate to the Forge or when using your own Artifactory server.
You will need to prepend your token with 'Bearer ' to authenticate to the Forge or when using Artifactory as your Forge server.

Choose a reason for hiding this comment

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

I suggest waiting to merge this until puppetlabs/forge-ruby#89 is merged and released, since it obviates the need to include 'Bearer'

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like that should work for Artifactory-based Forge too?

Copy link

@caseywilliams caseywilliams Aug 20, 2021

Choose a reason for hiding this comment

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

I think so, although I haven't checked that manually - I did manually verify just now that the version of forge-ruby I just released (3.1.0) will allow this to work with the forge API without prepending Bearer in the r10k.yaml setting. Otherwise, the only thing stopping r10k from authenticating before was the check for a baseurl that's removed in this PR.

Unless I'm missing something, it seems like the options here are to:

  • Update this README to suggest specifying Bearer <your-key> as the authorization_token setting for now (regardless of whether you're authenticating to the forge or to artifactory), and leave the forge-ruby dependency as-is
    or
  • Update the forge-ruby dependency to 3.1.0 and don't mention Bearer at all - the biggest impact from this would probably be that the default forge API url set by forge-ruby would update from https://forgeapi.puppetlabs.com to https://forgeapi.puppet.com.

Choose a reason for hiding this comment

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

I guess a third option would be to add new logic in r10k to prepend Bearer to the key as needed - it wouldn't affect forge-ruby behavior in 3.1.0, and it would let people omit Bearer in their r10k.yaml file if they're using an older forge-ruby version.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We talked about that and decided we didn't know enough about what token requirements other custom Forge implementations might have, and didn't want to introduce magic that was going to bite us. Though I guess if the Forge gem is doing that now, that point is kinda moot.

Copy link
Contributor

Choose a reason for hiding this comment

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

@caseywilliams Would the URL update in 3.1.0 that you mentioned cause breakages? I know we had some trouble updating that URL in r10k, so we're still using the puppetlabs one.

Choose a reason for hiding this comment

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

Yeah, it might - if I remember correctly, the PE acceptance tests were breaking last time we tested using the updated URL in r10k. forgeapi.puppet.com is really the current canonical place to find the API, so everyone should switch over eventually, but the two biggest issues in updating would be (as far as I can tell) (1) if a user had allowlisted access in their network to forgeapi.puppetlabs.com and then suddenly lost access when the url updated but their rules had not, and (2) needing to schedule the acceptance test update work

Copy link
Contributor

Choose a reason for hiding this comment

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

looks like bumping the puppet_forge gem to 3.1.0 will involve packaging a bunch of additional dependencies in pe-r10k-vanagon, since faraday 1.3+ has a bunch more dependencies than the version we're currently on.

I'm thinking it might be best to open a separate ticket/issue for bumping puppet_forge, removing the docs around Bearer , and updating the Forge API url. Would you mind doing that @caseywilliams?

Choose a reason for hiding this comment

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

Sure, wasn't sure exactly which jira project was appropriate but I filed PE-32770.

@@ -230,14 +230,6 @@ def call
runner.setup_settings
runner.setup_authorization
end

it 'errors if no custom forge URL is set' do
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be valuable to test that setting authorization_token now does work if baseurl isn't set?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Considering how mocked up this all is, not really IMO.

@Magisus
Copy link
Collaborator

Magisus commented Jul 30, 2021

Is it even possible to do manual testing right now, or does the forge not yet support token auth?

@mwaggett mwaggett added awaiting user feedback feature has jira ticket Label for issues that are duplicated in Jira labels Aug 5, 2021
@binford2k
Copy link
Contributor Author

There is Forge WIP that will need to land before this is actually functional. It shouldn't actually break anything, so it won't hurt anything to release early, but I'd wait until @carabasdaniel gives the go-ahead.

@mwaggett
Copy link
Contributor

mwaggett commented Aug 9, 2021

okay cool. yeah @binford2k I'd like to wait for that to land so that this can be manually tested before merging.

@caseywilliams
Copy link

caseywilliams commented Aug 10, 2021

This won't be ready for testing until PF-2447 is done - I've updated the jira ticket for this PR to reflect that. I'd prefer to wait until we can test with real data before we merge these changes.

@geoffnichols
Copy link

@binford2k and @mwaggett - when y'all get a chance to take a look at this again, it looks like PF-2447 was resolved yesterday!

@mwaggett
Copy link
Contributor

awesome, @binford2k would you mind rebasing and then doing some manual testing?

In the near future, the Forge will be adding support for authenticated
module downloads. This extends support for token based authentication to
that use case.
@binford2k
Copy link
Contributor Author

@mwaggett manually tested, works as expected 👍

@mwaggett mwaggett merged commit 758fee1 into puppetlabs:main Aug 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature has jira ticket Label for issues that are duplicated in Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants