-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[gRPC] Enable PATs to be used for authorizing with the gRPC API #19081
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
Conversation
2443926
to
e8e0eee
Compare
a29e3ea
to
abf7ad7
Compare
42f41fc
to
e9f13a8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code wise looks good, I did not try yet.
@geropl is going to change gpctl public-api-get-workspace to use gitpod/v1 that we can verify against internal CLI, i will test then
I tested though dummy service and it sill work with cookie auth. |
UPDATE: test it wrong, cli will not hit PR's changes ✅ Access Check (with ✅ API call
✅ regenerate
cc @filiptronicek it's nice to use cli for testing 🎉 . we need to check if we can have proper error message if token is invalidated |
@mustard-mh I think I got it wrong: The CLI is still based on |
e9f13a8
to
316ffbb
Compare
@akosyakov @mustard-mh Works now, and can be tested using the steps in the description ☝️ |
.map((s) => s.substring("function:".length)); | ||
if (functionScopes.length === 1 && functionScopes[0] === "*") { | ||
const { isAllAccessFunctionGuard, functionScopes } = FunctionAccessGuard.extractFunctionScopes(scopes); | ||
if (isAllAccessFunctionGuard) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geropl how can we test for a regression of this path manually? to use gitpod cli with PAT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. Still works 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested that it works from dashboard with gRPC and JSON RPC, and from cli against experimental and gitpod
i left some comments
316ffbb
to
b6dff1a
Compare
/unhold |
@@ -6,7 +6,8 @@ package cmd | |||
|
|||
import ( | |||
"github.com/gitpod-io/gitpod/common-go/log" | |||
v1 "github.com/gitpod-io/gitpod/components/public-api/go/experimental/v1" | |||
v1 "github.com/gitpod-io/gitpod/components/public-api/go/v1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description
Blocked by/based on: #19023Adds the ability to call the gRPC API with a PAT token. This works because PATs at the moment only supporting two "scopes":
Only if the "all functions" are allowed, we accept it for the gRPC API.
Summary generated by Copilot
🤖[deprecated] Generated by Copilot at a29e3ea
This pull request enhances the bearer token authentication and authorization logic for different kinds of subjects, such as users and tokens. It adds a new SubjectId class to represent subjects, a new extractFunctionScopes method to handle function scopes, and a new authExpressRequest method to authenticate express requests. It also renames and refactors some existing methods and functions for clarity and consistency. The affected files are
server.ts
,bearer-authenticator.ts
,function-access.ts
, andauthorizer.ts
.Related Issue(s)
Fixes EXP-897
How to test
dev/gpctl
export GPCTL_PUBLICAPI_TOKEN=<your pat>
go run main.go api ws ls <an org id> --address gpl-897-pat-api.preview.gitpod-dev.com
✔️go run main.go api ws get <ws id> --address gpl-897-pat-api.preview.gitpod-dev.com
✔️Documentation
Preview status
Gitpod was successfully deployed to your preview environment.
Build Options
Build
Run the build with werft instead of GHA
Run Leeway with
--dont-test
Publish
Installer
Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
If enabled this will build
install/preview
If enabled this will create the environment on GCE infra
Saves cost. Untick this only if you're really sure you need a non-preemtible machine.
Valid options are
all
,workspace
,webapp
,ide
,jetbrains
,vscode
,ssh
. If enabled,with-preview
andwith-large-vm
will be enabled./hold