0

我们的 Vault 配置为使用 github 令牌。如何使用 spring-cloud-vault 并使用 github 令牌?查看了所有文档和论坛。

提前致谢。

4

1 回答 1

1

Assuming "spring-cloud-vault" is the same as Hashicorp Vault (and according to https://cloud.spring.io/spring-cloud-vault/reference/html/ this looks pretty much the same!), you first need make sure the "github" auth method is enabled.

Our Vault is configured to use github tokens

So this seems to be the case already.

Next you need to create a GitHub personal token on https://github.com/settings/tokens. Click on "Generate new token" and in the "admin:org" scope, select "read:org", then generate the token and copy it. See this GitHub guide for additional help: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line

You will get a token code. With this you can log in to your Vault. In the Vault UI select "GitHub" as Method, then paste the copied token.

If you are using the Vault API, e.g. with curl, you need to add the token as a HTTP header:

$ curl -X POST \
--data '{"token": "YOURSECRETANDPERSONALGITHUBTOKEN" }' https://vault.example.com/v1/auth/github/login

Note that in this example Vault is behind a reverse proxy, therefore not using the port 8200 in the URL.

You should get a HTTP 200 and a json reponse when you successfully logged in. See https://www.vaultproject.io/docs/auth/github.html for more details.

于 2019-09-05T09:59:42.647 回答