Feat: Bearer token based auth for Pact Brokers #44
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It would be nice to also be able to support Bearer based tokens, for Bearer protected Brokers.
The Open source Pact Broker does not provide this out of the box, however PactFlow does, and users of the open source broker, may roll their own auth mechanisms to support a bearer token.
The following curl request will retrieve a pact from a bearer protected Broker (example PactFlow)
curl -H "Authorization: Bearer $PACT_BROKER_TOKEN" https://testdemo.pactflow.io/pacts/provider/pact-provider-poc/consumer/pact-consumer-poc/version/9191e17 | jq .
Most users will have the following combos of env vars, depending on their setup
PACT_BROKER_BASE_URL
Basic Auth
PACT_BROKER_USERNAME
PACT_BROKER_PASSWORD
Bearer Auth
PACT_BROKER_TOKEN
There it would be reasonable to assume, that these are set or are easily set in a users local, or ci environment.
Only read-only tokens are required, as no write actions are performed on a broker