-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: use env var instead of plain text for vault token #8866
Changes from 4 commits
aa8b1bd
7f938e2
c13c6ec
6bc6d61
111ac11
2d988b7
62eb6f9
26627b7
0868b43
c562216
206dd90
3aeed0d
6c8cf91
756f3b4
37a3406
d4d5fb3
30a296b
1626dce
46b992e
f2c1c27
9bfaede
234346a
8b72f12
74b3e66
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ local norm_path = require("pl.path").normpath | |
local sub = core.string.sub | ||
local rfind_char = core.string.rfind_char | ||
|
||
local env = require("apisix.core.env") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't we import it like |
||
|
||
local schema = { | ||
type = "object", | ||
|
@@ -56,7 +57,7 @@ local function make_request_to_vault(conf, method, key, data) | |
local res, err = httpc:request_uri(req_addr, { | ||
method = method, | ||
headers = { | ||
["X-Vault-Token"] = conf.token | ||
["X-Vault-Token"] = env.fetch_by_uri(conf.token) | ||
}, | ||
body = core.json.encode(data or {}, true) | ||
}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ run_case() { | |
export_or_prefix | ||
make init | ||
set_coredns | ||
export VAULT_TOKEN="root" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
# run test cases | ||
FLUSH_ETCD=1 prove --timer -Itest-nginx/lib -I./ -r ${TEST_FILE_SUB_DIR} | tee /tmp/test.result | ||
rerun_flaky_tests /tmp/test.result | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,7 +61,7 @@ __DATA__ | |
secrets: | ||
- id: vault/1 | ||
prefix: kv/apisix | ||
token: root | ||
token: "$ENV://VAULT_TOKEN" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we can no longer use such a configuration?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we won't be able to use such a configuration. Let me fix that quickly. |
||
uri: 127.0.0.1:8200 | ||
#END | ||
--- config | ||
|
@@ -86,7 +86,7 @@ property "uri" validation failed: failed to match pattern "^[^\\/]+:\\/\\/([\\da | |
secrets: | ||
- id: hhh/1 | ||
prefix: kv/apisix | ||
token: root | ||
token: "$ENV://VAULT_TOKEN" | ||
uri: 127.0.0.1:8200 | ||
#END | ||
--- config | ||
|
@@ -111,7 +111,7 @@ secret manager not exits | |
secrets: | ||
- id: vault/1 | ||
prefix: kv/apisix | ||
token: root | ||
token: "$ENV://VAULT_TOKEN" | ||
uri: http://127.0.0.1:8200 | ||
#END | ||
--- config | ||
|
@@ -133,7 +133,7 @@ GET /t | |
len: 1 | ||
id: vault/1 | ||
prefix: kv/apisix | ||
token: root | ||
token: $ENV://VAULT_TOKEN | ||
uri: http://127.0.0.1:8200 | ||
|
||
|
||
|
@@ -151,7 +151,7 @@ Success! Data written to: kv/apisix/apisix-key | |
secrets: | ||
- id: vault/1 | ||
prefix: kv/apisix | ||
token: root | ||
token: "$ENV://VAULT_TOKEN" | ||
uri: http://127.0.0.1:8200 | ||
#END | ||
--- config | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can avoid the blank line here? Other files don't add a blank line among localized variables.