hashicorp / vault-plugin-auth-kubernetes

Vault authentication plugin for Kubernetes Service Accounts
https://www.vaultproject.io/docs/auth/kubernetes.html
Mozilla Public License 2.0
206 stars 62 forks source link

Fix error code when using the wrong service account #144

Closed tomhjp closed 2 years ago

tomhjp commented 2 years ago

Previously, using a service account with the wrong name or from the wrong namespace gave:

Error making API request.

URL: PUT http://127.0.0.1:38200/v1/auth/kubernetes/login
Code: 500. Errors:

* service account name not authorized

Obviously, internal server error isn't the correct error code, so this PR updates that to be a 403:

Error making API request.

URL: PUT http://127.0.0.1:38200/v1/auth/kubernetes/login
Code: 403. Errors:

* service account name not authorized

I wanted to be able to test it for real with the plugin actually registered with Vault, and we don't really have much test infrastructure set up to help with that, so I made some automated integration tests that:

There's not much to the integration tests themselves yet, but it should make validating features against multiple Kubernetes versions much easier in future.

Finally, there's also some cleanup fixing docs/links and removing some now unused bits.

If we're happy to move forward with this, I'll remove the current CircleCI config too, as it's now covered in the GH actions workflow.

tomhjp commented 2 years ago

Agreed on the backport 👍 last thing to do before merging is just to sort out the CircleCI builds