-
Notifications
You must be signed in to change notification settings - Fork 21
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
OAuth2: Dynamic Secrets #697
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for kusk-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Is this still work in progress? |
ApiType: envoy_core_v3.ApiConfigSource_GRPC, | ||
RequestTimeout: durationpb.New(defaultRequestTimeout), | ||
GrpcServices: []*envoy_core_v3.GrpcService{makeGrpcService(cluster, "", defaultResponseTimeout)}, | ||
//SetNodeOnFirstMessageOnly: true, // Could someone please justify why this is set to `true`? |
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.
What does this setting even do?
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 entirely sure myself, but it seems to make a difference in secrets being discovered or not, what I mean is, if I leave this field in place, the secrets stays in dynamic_warming_secrets
object instead of the dynamic_active_secrets
object.
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.
@jasmingacic and @povilasv, any idea?
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.
Other than those minor tweak the code looks alright.
Is this still work in progress @mbana ?
feb1c8d
to
79ab348
Compare
Unfortunately I am seeing very weird behaviour. After I apply my API spec on a freshly deployed cluster, I see the secrets appearing as $ kubectl apply -f examples/auth/oauth2/authorization-code-grant
$ kubectl port-forward --namespace default deployment/default 19000:19000
$ curl -s 'http://localhost:19000/config_dump' | jq '.configs | last'
{
"@type": "type.googleapis.com/envoy.admin.v3.SecretsConfigDump",
"dynamic_warming_secrets": [
{
"name": "hmac-secret-606c6600-1a3e-4bb9-9d30-948526b80a74",
"version_info": "uninitialized",
"last_updated": "2022-09-07T19:07:52Z",
"secret": {
"@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret",
"name": "hmac-secret-606c6600-1a3e-4bb9-9d30-948526b80a74"
}
},
{
"name": "token-secret-2ae05632-00c3-4bea-bc4f-4eabbe4443ae",
"version_info": "uninitialized",
"last_updated": "2022-09-07T19:07:52Z",
"secret": {
"@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret",
"name": "token-secret-2ae05632-00c3-4bea-bc4f-4eabbe4443ae"
}
}
]
} After I restart the Envoy instance, I see them appearing in a different state, i.e., in
Due to all of this I've intentionally skipped the @jasmingacic and @aabedraba, I don't know what a user would prefer, editing the |
ef1925c
to
dcea0fa
Compare
If that's our only option to avoid manual configMap update, let's go for it. |
I agree. Let's do it |
dcea0fa
to
db27a80
Compare
@mbana what's the status on this? It is becoming stale we might have troubles merging it soon |
Support defining the secrets dynamically, i.e., they should appear as `dynamic_active_secrets` in the admin `/config_dump` page: ```sh $ kubectl port-forward --namespace default deployment/default 19000:19000 & $ curl -s 'http://localhost:19000/stats' | grep sds sds.client_secret_test_1.version_text: "690" sds.hmac_secret_test_1.version_text: "690" cluster.kubeshop-kusk-gateway-oauth2.eu.auth0.com.client_ssl_socket_factory.ssl_context_update_by_sds: 0 sds.client_secret_test_1.init_fetch_timeout: 0 sds.client_secret_test_1.key_rotation_failed: 0 sds.client_secret_test_1.update_attempt: 2 sds.client_secret_test_1.update_failure: 0 sds.client_secret_test_1.update_rejected: 0 sds.client_secret_test_1.update_success: 1 sds.client_secret_test_1.update_time: 1662408207693 sds.client_secret_test_1.version: 18219575566587264222 sds.hmac_secret_test_1.init_fetch_timeout: 0 sds.hmac_secret_test_1.key_rotation_failed: 0 sds.hmac_secret_test_1.update_attempt: 2 sds.hmac_secret_test_1.update_failure: 0 sds.hmac_secret_test_1.update_rejected: 0 sds.hmac_secret_test_1.update_success: 1 sds.hmac_secret_test_1.update_time: 1662408207693 sds.hmac_secret_test_1.version: 18219575566587264222 sds.client_secret_test_1.update_duration: P0(nan,0) P25(nan,0) P50(nan,0) P75(nan,0) P90(nan,0) P95(nan,0) P99(nan,0) P99.5(nan,0) P99.9(nan,0) P100(nan,0) sds.hmac_secret_test_1.update_duration: P0(nan,0) P25(nan,0) P50(nan,0) P75(nan,0) P90(nan,0) P95(nan,0) P99(nan,0) P99.5(nan,0) P99.9(nan,0) P100(nan,0) $ curl -s 'http://localhost:19000/config_dump' | jq '.[] | .[-1].dynamic_active_secrets' [ { "name": "client_secret_test_1", "version_info": "690", "last_updated": "2022-09-05T20:03:27.693Z", "secret": { "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret", "name": "client_secret_test_1", "generic_secret": { "secret": { "inline_string": "[redacted]" } } } }, { "name": "hmac_secret_test_1", "version_info": "690", "last_updated": "2022-09-05T20:03:27.693Z", "secret": { "@type": "type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.Secret", "name": "hmac_secret_test_1", "generic_secret": { "secret": { "inline_bytes": "W3JlZGFjdGVkXQ==" } } } } ] ``` Things to note from the above output are: 1. The secrets are in the `dynamic_active_secrets` object not in a `dynamic_warming_secrets` object, the later of which would mean that the secrets have not been sent to envoy. See <https://www.envoyproxy.io/docs/envoy/v1.23.1/api-v3/admin/v3/config_dump.proto#admin-v3-secretsconfigdump> for more information. As per the documentation `dynamic_active_secrets`: > "The dynamically loaded active secrets. These are secrets that are available to service clusters or listeners." 2. The output from the `/stats` endpoint shows no failures. Signed-off-by: Mohamed Bana <mohamed@bana.io>
I've made a local build with the changes in from envoyproxy/envoy#23356 (comment). It's available at:
I'll test it out and see if it works. |
db27a80
to
16230a2
Compare
The SDS fix has been merged into I suspect we will need to wait until |
Also, consider #743 once Envoy upstream issue is fixed. |
Support defining the secrets dynamically, i.e., they should appear as
dynamic_active_secrets
in the admin/config_dump
page:Things to note from the above output are:
dynamic_active_secrets
object not in adynamic_warming_secrets
object, the later of which would mean that the secrets have not been sent to envoy. See https://www.envoyproxy.io/docs/envoy/v1.23.1/api-v3/admin/v3/config_dump.proto#admin-v3-secretsconfigdump for more information. As per the documentationdynamic_active_secrets
:/stats
endpoint shows no failures.Signed-off-by: Mohamed Bana mohamed@bana.io
Summary
The main changes are in:
EnvoyConfiguration.GenerateSnapshot
.internal/envoy/auth/oauth2_filter.go
- use ADS as the config source.internal/envoy/config/hcm.go
- the removal ofSetNodeOnFirstMessageOnly
.dynamic_warming_secrets
and a restart of Envoy is required by doingcurl -X POST 'http://localhost:19000/quitquitquit
(given the port forward to the admin port is active):TODO
dynamic_active_secrets
and not indynamic_warming_secrets
. This just requires aGET
on the endpoint and checking that they are indeeddynamic_active_secrets
. Partially complete in that the structure of the test has been written.internal/envoy/config/hcm.go
and tell me whySetNodeOnFirstMessageOnly: true
is there in the first place? It seems like when it is set to true, the secrets remain in thedynamic_warming_secrets
object which won't allow dynamic secrets to be defined.