puppetlabs / vault-plugin-secrets-oauthapp

OAuth 2.0 secrets plugin for HashiCorp Vault supporting a variety of grant types
Apache License 2.0
94 stars 10 forks source link

Expose errors from underlying providers more helpfully #29

Closed impl closed 3 years ago

impl commented 3 years ago

Dependencies:

This change surfaces most errors from the provider package as "user" errors that get a proper response generated for them instead of a 500 error.

In particular, @DrDaveD will be happy to know that I've had a change of heart on #14, for two reasons:

By the way, the problem with returning 500s is that the Vault API client (the Go one, at least) just blindly retries those requests and masks the error that was originally returned, making debugging effectively impossible, as we learned this week.

Here's what an error response looks like now:

Error writing data to oauth/auth0/creds/test: Error making API request.

URL: PUT http://localhost:8200/v1/oauth/auth0/creds/test
Code: 400. Errors:

* exchange failed: oauth2: cannot fetch token: 403 Forbidden
Response: {"error":"invalid_grant","error_description":"Invalid authorization code"}
DrDaveD commented 3 years ago

I was aware that the go oauth2 library blindly retries errors when retrieving a token. It does this when it doesn't know the authentication style. It's very annoying. It can be avoided by telling it the authstyle.