-
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: support secret fetching in authz-keycloak #10291
Conversation
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Please make the ci pass |
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
done |
apisix/plugins/authz-keycloak.lua
Outdated
@@ -16,11 +16,13 @@ | |||
-- | |||
local core = require("apisix.core") | |||
local http = require "resty.http" | |||
local secret = require("apisix.secret") |
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.
I'm not sure but importing just fetch_secrets()
(instead of the whole module) might be more efficient. cc: @monkeyDluffy6017
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.
@Revolyssup please check this
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.
done
Co-authored-by: Abhishek Choudhary <shreemaan.abhishek@gmail.com>
pls add user document for guide |
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Updated the auth-keycloak plugin doc |
@@ -48,7 +48,7 @@ Refer to [Authorization Services Guide](https://www.keycloak.org/docs/latest/aut | |||
| token_endpoint | string | False | | https://host.domain/auth/realms/foo/protocol/openid-connect/token | An OAuth2-compliant token endpoint that supports the `urn:ietf:params:oauth:grant-type:uma-ticket` grant type. If provided, overrides the value from discovery. | | |||
| resource_registration_endpoint | string | False | | https://host.domain/auth/realms/foo/authz/protection/resource_set | A UMA-compliant resource registration endpoint. If provided, overrides the value from discovery. | | |||
| client_id | string | True | | | The identifier of the resource server to which the client is seeking access. | | |||
| client_secret | string | False | | | The client secret, if required. | | |||
| client_secret | string | False | | | The client secret, if required. You can use APISIX secret to store and reference this value. APISIX currently supports storing secrets in two ways. [Environment Variables](#use-environment-variables-to-manage-secrets) and [HashiCorp Vault](#use-vault-to-manage-secrets) | |
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.
The links are wrong. And please add an example as well.
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.
I fixed the doc link. Though the lint points to the secret page which has the example in detail. So I think it will be redundant to add it again here.
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.
Does this PR introduce support to use env vars for accessing secrets? If yes, please add tests as well.
Regarding the docs, it would be nice to have an example like this:
(existing example that uses hard-coded value for secrets)
You can also set secrets using the secret resource to avoid having sensitive information in plain text <-- add this line
(add a basic configuration here)
See (add link to secrets.md documentation) for more information.
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.
@shreemaan-abhishek Though secret is the APISIX abstraction. Behind it can be vault or env variable or anything. So I thought just testing with any one of them should work. Okay I will add tests for env variable as well.
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.
okay i will modify the test case
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Please take a look at this case, I think it might be better understood if you can directly check the value after reslove. apisix/t/plugin/authz-keycloak3.t Line 168 in 1434335
|
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
t/plugin/authz-keycloak4.t
Outdated
=== TEST 2: set client_secret as a reference to secret | ||
--- yaml_config | ||
apisix: | ||
data_encryption: |
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.
why need this ?
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.
the test case whose configuration I picked also had this so I copy pasted. Should I remove it?
@Sn0rt This variable extracts the exact string which is not a resolved secret. So the value of this will be |
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Signed-off-by: Ashish Tiwari <ashishjaitiwari15112000@gmail.com>
Closing this PR. Recreating this with clean commits. |
Description
Currently $secret uri cannot be used in authz-keycloak plugin. This PR adds support for it.
Checklist