pactflow / swagger-mock-validator

Other
14 stars 5 forks source link

Feat: Bearer token based auth for Pact Brokers #44

Open YOU54F opened 1 year ago

YOU54F commented 1 year ago

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