[supervisor] Initial design and implementation of the token service #1865
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a token service in supervisor.
(Note: the vast majority of additions in this PR is auto-generated protocol code or license header.)
Why do we need this?
In the past the Theia Gitpod extension, more specifically its frontend, acted as "proxy" towards the Gitpod API and relied on the user's session authentication to authenticate. Now that more and more functionality is moving towards supervisor and other clients (e.g. other IDEs), we need to ensure they, too can access the Gitpod API. Where #1868 introduces the "service side" of things, this PR introduces some infrastructure to make tokens practical in a workspace.
Idea
The idea is that we have a central service - supervisor - that acts as "doorman", collecting keys to various services (first and foremost, the Gitpod API, but also GitHub tokens). Supervisor clients - e.g. CLI or the supervisor frontend - can provide tokens upon request or prophylactically. They can also request tokens that were previously provided.
Ideally the supervisor frontend would, in the future, use its session auth to generate an API token that supports/enables the basic functioning of a workspace. It would be specifically scoped (
function:heartbeat, function:getWorkspace, resource:workspace::<thisWorkspaceID>::get
, etc.) and be made available to other consumers within the workspace by virtue of the supervisor token service.When someone in the workspace needs e.g. a GitHub token, they can also ask supervisor who would forward the request to its providers, e.g. the supervisor frontend. The frontend can then decide if it wants to deny the request, ask the user or just provide a token. This is in analogy to how the Git authentication works today, only that it's supervisor instead of Theia talking to the Gitpod server.
Controlling token reuse
Token provider can determine how supervisor gets to reuse the token they've provided. There are three modes:
function:openPort
and would be given a token that, amongst others hasfunction:openPort,resource:workspaceInstance::<thisWorkspaceInstanceID>::update
.Future work
gp
acts as credential helper to Git. Right now it asks Theia for the token, but should ask supervisor instead.