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

dashboard: add authority for archive experiments and events #1261

Merged

Conversation

WangXiangUSTC
Copy link
Contributor

@WangXiangUSTC WangXiangUSTC commented Dec 9, 2020

What problem does this PR solve?

add authority for archive experiments and events

What is changed and how does it work?

when querying the archive experiments and events, will use SelfSubjectAccessReviews to judge whether the token can list the information.

Checklist

Tests

  • Unit test
  • E2E test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Breaking backward compatibility

Related changes

  • Need to update the documentation

Does this PR introduce a user-facing change?

NONE

@WangXiangUSTC
Copy link
Contributor Author

@g1eny0ung I update the HTTP request on front-end at 408ef7d, PTAL

@WangXiangUSTC
Copy link
Contributor Author

/run-e2e-tests

pkg/apiserver/event/event.go Outdated Show resolved Hide resolved
ui/src/api/events.ts Outdated Show resolved Hide resolved
Signed-off-by: xiang <[email protected]>
@codecov-io
Copy link

codecov-io commented Dec 16, 2020

Codecov Report

Merging #1261 (d053930) into master (7e9ff3f) will decrease coverage by 4.20%.
The diff coverage is 52.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1261      +/-   ##
==========================================
- Coverage   55.78%   51.57%   -4.21%     
==========================================
  Files          68       78      +10     
  Lines        4383     5012     +629     
==========================================
+ Hits         2445     2585     +140     
- Misses       1768     2159     +391     
- Partials      170      268      +98     
Impacted Files Coverage Δ
api/v1alpha1/common_types.go 0.00% <0.00%> (ø)
api/v1alpha1/common_webhook.go 100.00% <ø> (ø)
api/v1alpha1/dnschaos_type.go 0.00% <0.00%> (ø)
api/v1alpha1/dnschaos_webhook.go 0.00% <0.00%> (ø)
api/v1alpha1/httpchaos_types.go 0.00% <0.00%> (ø)
api/v1alpha1/iochaos_types.go 0.00% <ø> (-40.00%) ⬇️
api/v1alpha1/jvmchaos_webhook.go 0.00% <0.00%> (ø)
api/v1alpha1/kernelchaos_types.go 0.00% <ø> (-20.00%) ⬇️
api/v1alpha1/kernelchaos_webhook.go 100.00% <ø> (+14.81%) ⬆️
api/v1alpha1/kinds.go 27.27% <ø> (+0.60%) ⬆️
... and 128 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ec70532...d053930. Read the comment docs.

g1eny0ung
g1eny0ung previously approved these changes Dec 17, 2020
Copy link
Member

@g1eny0ung g1eny0ung left a comment

Choose a reason for hiding this comment

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

LGTM

@WangXiangUSTC
Copy link
Contributor Author

@STRRL PTAL

Copy link
Member

@STRRL STRRL left a comment

Choose a reason for hiding this comment

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

How about printing some log when utils.CanListChaos return false.

The current implementation is NOT so good for presenting authorization failed with HTTP API:

  • It seems just to return empty results(not empty array[]) with HTTP status 200, and the frontend needs more logic to resolve it.
  • We should return 403 with authorization failed.

If this implementation is a temporary solution, just appending some logs is OK to me.

@WangXiangUSTC
Copy link
Contributor Author

How about printing some log when utils.CanListChaos return false.

The current implementation is NOT so good for presenting authorization failed with HTTP API:

  • It seems just to return empty results(not empty array[]) with HTTP status 200, and the frontend needs more logic to resolve it.
  • We should return 403 with authorization failed.

If this implementation is a temporary solution, just appending some logs is OK to me.

I take the gin.Context as a parameter of CanListChaos, and will take the error info to gin.Context, if CanListChaos return false, will print the error log in dashboard @STRRL

@STRRL
Copy link
Member

STRRL commented Dec 25, 2020

Oh, I missed it.🙈

But I think making errors in CanListChaos is not so good. 😰 Any operations about HTTP requests/response should be restricted in Controllers.

@cwen0
Copy link
Member

cwen0 commented Dec 28, 2020

Why not implementing a specific middleware to define this authority?

@@ -93,6 +93,11 @@ func (s *Service) list(c *gin.Context) {
name := c.Query("name")
ns := c.Query("namespace")

canList := utils.CanListChaos(c, ns)
if !canList {
return
Copy link
Member

Choose a reason for hiding this comment

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

Is it more reasonable to return some errors here, such as returning error codes (403 and so on?) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, you are right, I will refine this logic, maybe use the middleware @cwen0 mentioned

Signed-off-by: xiang <[email protected]>
@WangXiangUSTC
Copy link
Contributor Author

Why not implementing a specific middleware to define this authority?

refine this logic by using the middleware in 584aa18, PTAL again @STRRL @cwen0 @g1eny0ung @fewdan

Signed-off-by: xiang <[email protected]>
Copy link
Member

@fewdan fewdan left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@g1eny0ung g1eny0ung left a comment

Choose a reason for hiding this comment

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

LGTM

@g1eny0ung
Copy link
Member

/merge

@ti-srebot
Copy link
Contributor

/run-all-tests

@WangXiangUSTC
Copy link
Contributor Author

/run-e2e-tests

@ti-srebot ti-srebot merged commit f34ed1e into chaos-mesh:master Dec 30, 2020
@WangXiangUSTC WangXiangUSTC deleted the xiang/dashboard_token_refine branch December 30, 2020 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants