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

Argo Server with SSO enabled should not require List on all Secrets #8534

Closed
jessesuen opened this issue Apr 29, 2022 · 6 comments · Fixed by #8555
Closed

Argo Server with SSO enabled should not require List on all Secrets #8534

jessesuen opened this issue Apr 29, 2022 · 6 comments · Fixed by #8555
Labels
area/api Argo Server API area/server area/sso-rbac type/bug type/regression Regression from previous behavior (a specific type of bug) type/security Security related

Comments

@jessesuen
Copy link
Member

jessesuen commented Apr 29, 2022

Summary

When Argo Server starts up with SSO, it will call cache.NewResourceCache():

func NewArgoServer(ctx context.Context, opts ArgoServerOpts) (*argoServer, error) {
	configController := config.NewController(opts.Namespace, opts.ConfigName, opts.Clients.Kubernetes)
	var resourceCache *cache.ResourceCache = nil
	ssoIf := sso.NullSSO
	if opts.AuthModes[auth.SSO] {
		c, err := configController.Get(ctx)
		if err != nil {
			return nil, err
		}
		ssoIf, err = sso.New(c.SSO, opts.Clients.Kubernetes.CoreV1().Secrets(opts.Namespace), opts.BaseHRef, opts.TLSConfig != nil)
		if err != nil {
			return nil, err
		}
		resourceCache = cache.NewResourceCache(opts.Clients.Kubernetes, ctx, getResourceCacheNamespace(opts))
		log.Info("SSO enabled")
	} else {
		log.Info("SSO disabled")
	}

But NewResourceCache wants the ability to list all service accounts and all secrets of the entire cluster.

func NewResourceCache(client kubernetes.Interface, ctx context.Context, namespace string) *ResourceCache {
	informerFactory := informers.NewSharedInformerFactoryWithOptions(client, time.Minute*20, informers.WithNamespace(namespace))
	cache := &ResourceCache{
		ServiceAccountLister: informerFactory.Core().V1().ServiceAccounts().Lister(),
		SecretLister:         informerFactory.Core().V1().Secrets().Lister(),
	}
	informerFactory.Start(ctx.Done())
	informerFactory.WaitForCacheSync(ctx.Done())
	return cache
}

There are two problems with this:

  1. While list ServiceAccounts might be acceptable, listing all secrets of the cluster is generally unacceptable.
  2. This does not work with an Argo Server running with --namespaced mode

Instead of listing all secrets, I think we could look up the secret of the ServiceAccount on-demand, to find the bearer token. This will allow administrators to only give the controller limited permissions to Secrets. If the use of a Lister was because of performance, we could cache this in-memory rather than rely on a lister.

Use Cases

When would you use this?

In a secure, multi-tenant environment.


Message from the maintainers:

Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.

@jessesuen jessesuen added type/feature Feature request type/security Security related area/api Argo Server API labels Apr 29, 2022
@jessesuen
Copy link
Member Author

This does not work with an Argo Server running with --namespaced mode

ResourceCache was introduced in #6990

@basanthjenuhb -- I think this could be considered a regression because --namespaced flag is broken when SSO is enabled.

@jessesuen jessesuen added type/bug type/regression Regression from previous behavior (a specific type of bug) and removed type/feature Feature request labels Apr 29, 2022
@jessesuen
Copy link
Member Author

Also, having a cluster-wide informer on Secrets (and/or ConfigMaps) is never really a good idea. It will balloon the memory requirements of the server unnecessarily because these two objects tend to contain a lot of data. We learned this the hard way with Argo Rollout controller.

At the very least, this can be restricted to label filters. But as I mentioned in the description, I think list/watch on Secrets is an unnecessary requirement that should be removed.

@basanthjenuhb
Copy link
Contributor

basanthjenuhb commented Apr 29, 2022

we had discusses label filters.
We cannot do label filters because the secrets we are looking for are created automatically by serviceaccounts, and they don't have any label for them.

I am open to removing the list and just do get for every call
My initial thought process was the secrets are generally very small in size, and won't have much impact on memory
@alexec should I proceed with this change

@alexec
Copy link
Contributor

alexec commented Apr 29, 2022

Yes please. If we can remove the list secrets, that’d be great. You could use an lru cache to hold them.

@basanthjenuhb
Copy link
Contributor

Using a cache would again lead us to unnecessary cache invalidation issues .
Will just do get everytime

@basanthjenuhb
Copy link
Contributor

@alexec @jessesuen Please review. #8555

alexec pushed a commit that referenced this issue May 13, 2022
This was referenced Jun 20, 2022
@sarabala1979 sarabala1979 mentioned this issue Jul 30, 2022
51 tasks
BhavikaSharma pushed a commit to BhavikaSharma/argo-workflows that referenced this issue Sep 5, 2022
BhavikaSharma pushed a commit to BhavikaSharma/argo-workflows that referenced this issue Sep 5, 2022
BhavikaSharma pushed a commit to BhavikaSharma/argo-workflows that referenced this issue Sep 6, 2022
terrytangyuan pushed a commit to akuity/argo-workflows that referenced this issue Sep 7, 2022
terrytangyuan pushed a commit to akuity/argo-workflows that referenced this issue Sep 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Argo Server API area/server area/sso-rbac type/bug type/regression Regression from previous behavior (a specific type of bug) type/security Security related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants