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

auth: implement re-authentication in case of rotated certificates #25927

Conversation

mhofstetter
Copy link
Member

@mhofstetter mhofstetter commented Jun 6, 2023

This PR introduces mutual auth re-authentication. Whenever an
authhandler is emiting CertificateRotatedEvents, an authentication will
be triggered.

In addition, the existing authentication flow has been refactored to use the hive job framework.

Fixes #25475

@mhofstetter mhofstetter added kind/enhancement This would improve or streamline existing functionality. release-note/misc This PR makes changes that have no direct user impact. area/servicemesh GH issues or PRs regarding servicemesh release-blocker/1.14 This issue will prevent the release of the next version of Cilium. labels Jun 6, 2023
@mhofstetter mhofstetter requested a review from a team as a code owner June 6, 2023 09:18
@mhofstetter mhofstetter requested a review from meyskens June 6, 2023 09:18

func handleAuthentication(a *authManager, k authKey, reAuth bool) {
if a.markPendingAuth(k) {
go func(key authKey) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Kind of wonder whether we really want to keep a dedicated go-routine for every (re-)authentication request.

I tend to an implementation with a worker-pool which is working on the auth requests. This would be easier to test and prevent the manager from overload the authhandlers (e.g. SPIRE).

But keeping it as is for the context of this PR.

This commit refactors the authentication triggered by the signal map to
use the hive job framework.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
This commit introduces mutual auth re-authentication. Whenever an
authhandler is emiting CertificateRotatedEvents, an authentication will
be triggered.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
@mhofstetter mhofstetter force-pushed the pr/mhofstetter/authmanager-reauthentication branch from 9c18657 to 2fdb7fe Compare June 6, 2023 09:52
Copy link
Member

@meyskens meyskens left a comment

Choose a reason for hiding this comment

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

LGTM looks like a clean approach :)

A worker pool would be a good improvement for drop-in deployments of spire where it would immediately create spire IDs at the same time so they all get the same renewal schedule. However it could also be a good follow up pr imo.

@mhofstetter
Copy link
Member Author

mhofstetter commented Jun 6, 2023

/test

Job 'Cilium-PR-K8s-1.26-kernel-net-next' failed:

Click to show.

Test Name

K8sAgentPolicyTest Multi-node policy test with L7 policy using connectivity-check to check datapath

Failure Output

FAIL: cannot install connectivity-check

Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.26-kernel-net-next/500/

If it is a flake and a GitHub issue doesn't already exist to track it, comment /mlh new-flake Cilium-PR-K8s-1.26-kernel-net-next so I can create one.

Then please upload the Jenkins artifacts to that issue.

@mhofstetter
Copy link
Member Author

mhofstetter commented Jun 6, 2023

/test-1.26-net-next

-> testrun flaked with #13071

@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jun 6, 2023
@dylandreimerink dylandreimerink merged commit ebb6fc3 into cilium:main Jun 7, 2023
61 checks passed
@mhofstetter mhofstetter deleted the pr/mhofstetter/authmanager-reauthentication branch June 7, 2023 06:14
giorio94 added a commit to giorio94/cilium that referenced this pull request Jun 8, 2023
This commit adds back the stream package import, which appears to be
missing due to a merge race between cilium#25927 and cilium#25934.

Fixes: eb653b6 ("auth: use Resource.Observe for jobs")
Fixes: ebb6fc3 ("auth: implement re-authentication in case of rotated certificates")
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
dylandreimerink pushed a commit that referenced this pull request Jun 8, 2023
This commit adds back the stream package import, which appears to be
missing due to a merge race between #25927 and #25934.

Fixes: eb653b6 ("auth: use Resource.Observe for jobs")
Fixes: ebb6fc3 ("auth: implement re-authentication in case of rotated certificates")
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
mhofstetter added a commit to mhofstetter/cilium that referenced this pull request Jun 16, 2023
Until now, auth map entries were garbage collected based on the
following criterias:

* related identity has been deleted
* related node has been deleted
* entry has been expired

The initial goal was that expiration will cover the case where no longer
a policy is enforcing authentication.

But the introduction of re-authentication (cilium#25927) changed this, because
the entries would have re-authenticated "forever" (until identity or
node would have been deleted).

Therefore, this commit introduces some rudimentary garbage collection
based on policies by periodically checking whether a policy is still
enforcing authentication between two identities. If not, the auth map
entry gets deleted.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
tklauser pushed a commit that referenced this pull request Jun 16, 2023
Until now, auth map entries were garbage collected based on the
following criterias:

* related identity has been deleted
* related node has been deleted
* entry has been expired

The initial goal was that expiration will cover the case where no longer
a policy is enforcing authentication.

But the introduction of re-authentication (#25927) changed this, because
the entries would have re-authenticated "forever" (until identity or
node would have been deleted).

Therefore, this commit introduces some rudimentary garbage collection
based on policies by periodically checking whether a policy is still
enforcing authentication between two identities. If not, the auth map
entry gets deleted.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
romanspb80 pushed a commit to romanspb80/cilium that referenced this pull request Jun 22, 2023
This commit adds back the stream package import, which appears to be
missing due to a merge race between cilium#25927 and cilium#25934.

Fixes: eb653b6 ("auth: use Resource.Observe for jobs")
Fixes: ebb6fc3 ("auth: implement re-authentication in case of rotated certificates")
Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
romanspb80 pushed a commit to romanspb80/cilium that referenced this pull request Jun 22, 2023
Until now, auth map entries were garbage collected based on the
following criterias:

* related identity has been deleted
* related node has been deleted
* entry has been expired

The initial goal was that expiration will cover the case where no longer
a policy is enforcing authentication.

But the introduction of re-authentication (cilium#25927) changed this, because
the entries would have re-authenticated "forever" (until identity or
node would have been deleted).

Therefore, this commit introduces some rudimentary garbage collection
based on policies by periodically checking whether a policy is still
enforcing authentication between two identities. If not, the auth map
entry gets deleted.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/servicemesh GH issues or PRs regarding servicemesh kind/enhancement This would improve or streamline existing functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-blocker/1.14 This issue will prevent the release of the next version of Cilium. release-note/misc This PR makes changes that have no direct user impact.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Mutual Auth: Re-Authentication based on CertificateRotation Events
3 participants