pact-foundation / pact_broker-client

A Ruby and CLI client for the Pact Broker. Publish and retrieve pacts and verification results.
MIT License
69 stars 48 forks source link

Document how bearer token authentication works #77

Closed JulianCBC closed 4 years ago

JulianCBC commented 4 years ago

Following on from #66 I ended up in a similar situation where I wanted to bypass some third party authentication for our CI builds and ended up rolling my own version of the server-side part of the bearer token authentication.

It would be nice if the way that authentication works was documented as that would have saved me a lot of time and effort.

Something like:

## Authentication

### Basic Auth

Calculates a basic auth header based on the `--broker-username` and `--broker-password` parameters or ... environment variables and passes that with all requests

... example goes here ...

### Bearer Token

This passes the value provided in the `--broker-token` parameter or `...` environment variable in a `Authorization` header prefixed with the word "bearer".

Example header:

Authorization: Bearer abcdef1234567890

If it would be helpful, I'm more than happy to document how my particular setup is configured.

bethesque commented 4 years ago

If you would like to contribute that documentation, please feel free to submit a PR.

JulianCBC commented 4 years ago

I definitely will, however I'm raising the issue first in case it spurs someone with more knowledge and free time to do it before I can. 😂

bethesque commented 4 years ago

They're pretty standard mechanisms, hence why it would never have occurred to me to document them. If anyone googles "basic auth" or "bearer auth" there are many pages available.

JulianCBC commented 4 years ago

🤦 I was searching for "pact broker bearer auth" and getting nothing useful, I'd never heard of "bearer auth" before so I thought it was something custom.

I'll write up the documentation and submit a pull request with it, but feel free to close this.

JulianCBC commented 4 years ago

Ok, as discussed, I've written up some documentation on the Pact Broker authentication including documenting the environment variables that can be used instead of the command line parameters so my PR isn't completely pointless.

Thanks for your patience.