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

NETOBSERV-855 add authentication checks #277

Merged
merged 3 commits into from
Feb 1, 2023
Merged

Conversation

jotak
Copy link
Member

@jotak jotak commented Feb 1, 2023

No description provided.

@openshift-ci
Copy link

openshift-ci bot commented Feb 1, 2023

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jotak by writing /assign @jotak in a comment. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

}
hlog.Debug("Checking auth: kube config created")

_, err = client.CoreV1().Namespaces().List(ctx, v1.ListOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about relying on client.AuthorizationV1().SelfSubjectAccessReviews() here ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or just client.AuthenticationV1().TokenReviews() if you don't want to check any role

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking if a token is valid by trying to list namespaces with it looks a bit hacky.
As a first quick fix this is fine but we should look for a better solution IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll check what Julien suggests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I think for a quick fix we should go ahead with GetNamespaces, bc using SSAR / TokenReviews requires permission from the console plugin to create these objects (so need changes in the operator etc.)

Also, I remember to have seen a similar issue and the GetNamespaces solution (call it a hack if you want :) ) was used because working with more k8s distributions (including ones that don't necessarily have RBAC out of the box)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe just add a TODO comment in that case

)

func setupRoutes(cfg *Config) *mux.Router {
r := mux.NewRouter()
r.Use(func(orig http.Handler) http.Handler {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand correctly, all endpoints will be behind authentication.

We should exclude from authentication the /metrics endpoint and the fronted static files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm I think we still need to do that? We still don't want metrics or whatever being accessible from unauthenticated users?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OlivierCazade I've removed the metrics endpoint for the time being

}
hlog.Debug("Checking auth: kube config created")

_, err = client.CoreV1().Namespaces().List(ctx, v1.ListOptions{})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking if a token is valid by trying to list namespaces with it looks a bit hacky.
As a first quick fix this is fine but we should look for a better solution IMO.

@openshift-ci openshift-ci bot added the lgtm label Feb 1, 2023
@jotak jotak merged commit d734248 into netobserv:main Feb 1, 2023
jotak added a commit to jotak/network-observability-console-plugin that referenced this pull request Feb 1, 2023
* NETOBSERV-855 add authentication checks

* Update tests

* temporary removal of metrics endpoint
jotak added a commit to jotak/network-observability-console-plugin that referenced this pull request Feb 1, 2023
* NETOBSERV-855 add authentication checks

* Update tests

* temporary removal of metrics endpoint
jotak added a commit that referenced this pull request Feb 2, 2023
* NETOBSERV-855 add authentication checks

* Update tests

* temporary removal of metrics endpoint
jotak added a commit that referenced this pull request Feb 2, 2023
* NETOBSERV-855 add authentication checks

* Update tests

* temporary removal of metrics endpoint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants