Skip to content

Commit

Permalink
(PF-2437) Allow r10k to authenticate to the Forge
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
binford2k committed Jul 28, 2021
1 parent 0ba9a05 commit 91dad73
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
5 changes: 2 additions & 3 deletions doc/dynamic-environments/configuration.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,8 @@ This defaults to 'https://forgeapi.puppetlabs.com'

#### authorization_token

The 'authorization_token' setting allows you to provide a token for authenticating to a
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.

```yaml
forge:
Expand Down
8 changes: 1 addition & 7 deletions lib/r10k/initializers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,7 @@ class ForgeInitializer < BaseInitializer
def call
with_setting(:baseurl) { |value| PuppetForge.host = value }
with_setting(:proxy) { |value| PuppetForge::Connection.proxy = value }
with_setting(:authorization_token) { |value|
if @settings[:baseurl]
PuppetForge::Connection.authorization = value
else
raise R10K::Error, "Cannot specify a Forge authorization token without configuring a custom baseurl."
end
}
with_setting(:authorization_token) { |value| PuppetForge::Connection.authorization = value }
end
end
end
Expand Down
8 changes: 0 additions & 8 deletions spec/unit/action/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,6 @@ def call
runner.setup_settings
runner.setup_authorization
end

it 'errors if no custom forge URL is set' do
options = { config: "spec/fixtures/unit/action/r10k_forge_auth_no_url.yaml" }
runner = described_class.new(options, %w[args yes], action_class)
expect(PuppetForge::Connection).not_to receive(:authorization=).with('faketoken')

expect { runner.setup_settings }.to raise_error(R10K::Error, /Cannot specify a Forge auth/)
end
end

context "license auth" do
Expand Down

0 comments on commit 91dad73

Please sign in to comment.