Commit 58c85e27 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

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 ```
parents b32639f9 86eb95b0
...@@ -49,6 +49,10 @@ func (r *REST) Create(ctx genericapirequest.Context, obj runtime.Object, include ...@@ -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)) 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 { if r.tokenAuthenticator == nil {
return tokenReview, nil return tokenReview, nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment