mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #49698 from m1093782566/validate-tokenreview
Automatic merge from submit-queue Validate token length of TokenReview **What this PR does / why we need it**: I find API Resource TokenReview has no validation yet. Without validation, client may post unexpected data to API Server. I think we need to validate it before processing it. This PR Validate TokenReview Resource. Fixes #50588 **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
This commit is contained in:
commit
58c85e278b
@ -49,6 +49,10 @@ func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, include
|
||||
return nil, apierrors.NewBadRequest(fmt.Sprintf("namespace is not allowed on this type: %v", namespace))
|
||||
}
|
||||
|
||||
if len(tokenReview.Spec.Token) == 0 {
|
||||
return nil, apierrors.NewBadRequest(fmt.Sprintf("token is required for TokenReview in authentication"))
|
||||
}
|
||||
|
||||
if r.tokenAuthenticator == nil {
|
||||
return tokenReview, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user