**UPDATE: Closing this without action, based on thorough discussion in the thread below: #409038 (comment 1375291424) **
Description
See the following TODO regarding:
# TODO: Add proper authorization check here. Not sure what it should check, we can look at other services # which are called from ee/lib/ee/api/internal/kubernetes.rb for inspiration, e.g. # StarboardVulnerabilityCreateService and StarboardVulnerabilityResolveService which # use :admin_vulnerability
Note that there is already agent-token-based auth in place at these REST API endpoints at the Grape DSL level, this is just to follow our practices of defense in depth to authorize at the service levels too.
0 of 2 checklist items completed
· Edited by
Chad Woolley
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
Is the user we use to check authorization for an agent token the user that created the agent token, or the user that created the agent? (these are different sometimes? e.g when a different user generates a new token)
Under what circumstances do we want to prevent ReconcileService from executing?
e.g if a user has the authorization to reconcile a workspace revoked, then the workspaces go out of sync with the actual state. Is that ever desirable?
Similarly does it ever make sense to let agent configuration go out of sync?
Is the user we use to check authorization for an agent token the user that created the agent token, or the user that created the agent? (these are different sometimes? e.g when a different user generates a new token)
What do you mean? Authz check for an agent shouldn't depend on who created the agent or the token if that's what you are asking about.
Right, that's what I was about to say. There's no concept of a user involved - it's the agent which has been registered which provides the authentication scope.
But for our case, I'm not sure what authorization based on the agent we could or should check here?
What actions does the agent perform using those APIs?
This is the part of the architecture that handles the reconciliation polling loop, to reconcile the workspaces' actual state with the user's specified desired state.
What I'm struggling to wrap my head around is what "unauthorized" would mean in this scenario.
If an agent is registered and running in a cluster, and has authenticated and connected successfully through the kas proxy, when would we ever want to prevent it from doing its job of successfully completing a reconciliation polling loop?
It is notable that StarboardVulnerabilityCreateService and StarboardVulnerabilityResolveServicedo checkagent.created_by_user` for authorization, but that might make sense for that feature.
What I'm struggling to wrap my head around is what "unauthorized" would mean in this scenario.
If an agent is registered and running in a cluster, and has authenticated and connected successfully through the kas proxy, when would we ever want to prevent it from doing its job of successfully completing a reconciliation polling loop?
This is where I got stuck too hence my last 2 questions
Does it seem like there's perhaps nothing to add here wrt to authorization? at least at the moment? i.e the task is to just remove the TODOs
It is notable that StarboardVulnerabilityCreateService and StarboardVulnerabilityResolveService do check agent.created_by_user for authorization, but that might make sense for that feature.
Yes, that's specific to that feature. The author is used later to check that the user who created the agent has permission to administer the vulnerability.
But in our case, this request from the agent is handling potentially any workspace owned by any user.
In other words, we don't have any relationship between the user/project associated with the agent, and the user/project associated with a workspace. They are completely independent, other than the fact that the workspace's agent defines where the workspace is created and runs.
But instead of just removing the TODOs, I would change them into a NOTE which links to this discussion, and briefly summarizes why we are not doing authorization for defense in depth in this service method.
From my understanding this seems fine too. The agent only has access to resources it created, and communication with the agent is done through the Gitlab Workspaces Proxy which has authz checks, right?
Correct, an agent only handles reconciliation for the workspaces it is associated with.
and communication with the agent is done through the Gitlab Workspaces Proxy which has authz checks, right?
Yes, there is token based authentication, although I don't know if this would strictly be considered authorization. I think the token validity (i.e. authentication) is all that's really checked.
@bwill@adamcohen@smtan Could you clarify why the code needs to check the user? If the user becomes suspended/etc, agent might still be used by a customer. Features we (groupenvironments) build don't depend on the agent creator user for authz, I think we should be consistent.
Agent should be viewed as an independent identity, although we lack a way to actually make it an identity. One day we might get Service accounts and use them, but looks like the plan is to put them into GitLab Premium and we might not be able to use them for the agent in that case.
@ash2k I agree that isn't not ideal, but the agent doesn't have an identity and vulnerabilities are required to have an author. The only idea I have to get around that is to use an internal user instead.