Skip to content
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

implement periodic JWKs fetcher/updater #150

Merged
merged 13 commits into from
Aug 27, 2021

Conversation

Shikugawa
Copy link
Collaborator

Implement to fetch JWKs periodically and update them.

config/oidc/config.proto Outdated Show resolved Hide resolved
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
@Shikugawa Shikugawa marked this pull request as ready for review August 23, 2021 15:29
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
config/oidc/config.proto Outdated Show resolved Hide resolved
src/common/http/http.cc Outdated Show resolved Hide resolved
src/common/http/http.cc Outdated Show resolved Hide resolved
ioc_(io_context),
duration_(duration),
timer_(ioc_, duration_) {
timer_.async_wait(
Copy link

@incfly incfly Aug 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR does not include the usage of dynamic jwk resolver yet. but we should be caurefull: initialize the filter/filter chain/authservice and mark it complete only when we get a valid jwks for the first time. otherwise we could receive ExternalAuthz.Check request before jwks is initalized.

wondering how that would be done. hopefully you already got some solution/idea. :)

Copy link
Collaborator Author

@Shikugawa Shikugawa Aug 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should support to track existing dynamic JWKs state (such as valid, not valid or not initialized) here. It is because if we don't have valid JWKs, the ext_authz request will be rejected. Envoy will receive kicked request with invalid JWKs no matter when we have invalid (or not initialized) JWKs. Could you show the detailed pitfalls when we won't do that?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After authservice started, when the first check request comes, it may or may not have jwks fetched ready. So the request may or may not goes through. This won't cause any security problem. but it makes system less predictable from an end user perspective.

Plus this can happen when the authservices are doing a rolling restart. Without this, k8s switched to the new pods right away, even the new pod may not be ready yet (lacking jwks). So the valid requests can fail.

We could add a http endpoint, /readyz, returning 200 only when the jwks is resolved. And configure k8s readiness probe using that. With this, k8s won't swap the new authservice pods util it says it's ready to serve.

No action item on this PR.

@incfly
Copy link

incfly commented Aug 27, 2021 via email

Signed-off-by: Shikugawa <[email protected]>
Signed-off-by: Shikugawa <[email protected]>
setExpectedRemoteJwks(*mock_http, valid_jwt_public_key2_);
io_context.run_for(std::chrono::seconds(3));
EXPECT_EQ(google::jwt_verify::Status::Ok, resolver.jwks()->getStatus());
EXPECT_EQ(valid_jwt_public_key2_, resolver.rawStringJwks());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! :)

Copy link

@incfly incfly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes!

@istio-testing
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: incfly, Shikugawa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@incfly incfly merged commit ec7f5c4 into istio-ecosystem:master Aug 27, 2021
@Shikugawa Shikugawa deleted the jwk-fetcher branch August 27, 2021 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants