cloudfoundry / cf-k8s-networking

building a cloud foundry without gorouter....
Apache License 2.0
32 stars 17 forks source link

fix: url encode UAA oAuth client credentials #26

Closed tcdowney closed 4 years ago

tcdowney commented 4 years ago

Although this header was base64 encoded, the oAuth spec requires that is also be url encoded. This was causing client credentials that contained special characters (e.g. +) to be rejected by UAA:

{"error":"uaa get token: bad response, code 401: {\"error\":\"unauthorized\",\"error_description\":\"Bad credentials\"}","level":"error","msg":"fetching","time":"2020-02-18T23:49:41Z"}

The client identifier is encoded using the "application/x-www-form-urlencoded" encoding algorithm per Appendix B, and the encoded value is used as the username; the client password is encoded using the same algorithm and used as the password.

https://tools.ietf.org/html/rfc6749#section-2.3.1

Related: https://github.com/golang/oauth2/issues/320

Tracker Story: #171268188

Thanks to @joshuatcasey for helping me make sense of the oAuth spec!