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:
Kubernetes Submit Queue 2017-08-13 23:59:11 -07:00 committed by GitHub
commit 58c85e278b

View File

@ -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
}