-
Notifications
You must be signed in to change notification settings - Fork 10
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
feat: Use ServiceAccount to generate token #10
Conversation
Skipping CI for Draft Pull Request. |
bd24d0b
to
b0da5c5
Compare
b0da5c5
to
33bc4bd
Compare
c89d272
to
b39a234
Compare
c79d26d
to
77a1fd5
Compare
} | ||
|
||
namespace := request.PathParameter("namespace") | ||
name := request.PathParameter("name") |
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'd change it to vmName
.
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've added a few comments. I'll review again next week.
Created a new package for the service files. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
The same setup will be useful for new tests added in a future commit. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
This will be useful in a future commit. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
Moved parameter reading to a method. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
The tokens are generated by kubernetes API server, and they are bound to a service account. They can be used to access VMI/vnc subresource. /vnc endpoint was removed. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
b89264e
to
242bc14
Compare
@0xFelix, I have removed one commit from this PR to make it simpler. I will post the changes that you requested as a future PR. |
|
||
authToken := getAuthToken(request) | ||
if authToken == "" { | ||
_ = response.WriteError(http.StatusUnauthorized, fmt.Errorf("authenticating token cannot be empty")) |
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.
IMO we should not give more info on 401. We could potentially log internally, but over the API I would not return more information to a potential attacker than necessary.
|
||
err = s.checkVncRbac(request.Request.Context(), authToken, params.name, params.namespace) | ||
if err != nil { | ||
_ = response.WriteError(http.StatusUnauthorized, err) |
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.
Same.
Get(ctx context.Context, name string, opts metav1.GetOptions) (PT, error) | ||
} | ||
|
||
func createOrUpdate[PT interface { |
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.
Could this and L332 be part of a library? I see those kind of functions duplicated a lot across our projects.
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.
The retryOnConflict()
function is nearly a copy of this one from k8s.io/client-go
: https://github.com/kubernetes/client-go/blob/64a35f6a46ec8a791d437495fd91c87bcd01a5b5/util/retry/util.go#L48-L66
Where are they duplicated?
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'm okay with this in general, but please address the comments in follow ups.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 0xFelix The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
The /vnc endpoint functionality was removed. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
Changed documentation according to the new implementation. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
The example client connects to the kubevirt VMI/vnc endpoint. Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
242bc14
to
a99b0f2
Compare
Thanks! |
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.
/lgtm
Hooray! |
What this PR does / why we need it:
This PR adds an alternate implementation of the proxy.
/vnc
subreosurce on KubevirtVirtualMachineInstance
.Release note: