Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8afb10e

Browse files
authored
chore: improve validation of Security tag in swaggerparser (#15660)
Aims to resolve #15605 There's currently one option valid for the `@Security` tag in swaggerparser - which fails in the CI if we try to put any other value. At least one of our endpoints does not accept `CoderSessionToken` as an option for the authentication and so we need to add new possibilities in order to keep the documentation up-to-date. In this PR , I added `ProvisionerKey` which is the way our provisioner daemon can authenticate to the backend - also modified a bit the code to simplify other options later.
1 parent 60ddcf5 commit 8afb10e

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

coderd/apidoc/docs.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/coderdtest/swaggerparser.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,11 @@ func assertPathParametersDefined(t *testing.T, comment SwaggerComment) {
300300
}
301301

302302
func assertSecurityDefined(t *testing.T, comment SwaggerComment) {
303+
authorizedSecurityTags := []string{
304+
"CoderSessionToken",
305+
"CoderProvisionerKey",
306+
}
307+
303308
if comment.router == "/updatecheck" ||
304309
comment.router == "/buildinfo" ||
305310
comment.router == "/" ||
@@ -308,7 +313,7 @@ func assertSecurityDefined(t *testing.T, comment SwaggerComment) {
308313
comment.router == "/users/otp/change-password" {
309314
return // endpoints do not require authorization
310315
}
311-
assert.Equal(t, "CoderSessionToken", comment.security, "@Security must be equal CoderSessionToken")
316+
assert.Containsf(t, authorizedSecurityTags, comment.security, "@Security must be either of these options: %v", authorizedSecurityTags)
312317
}
313318

314319
func assertAccept(t *testing.T, comment SwaggerComment) {

docs/reference/api/enterprise.md

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

enterprise/coderd/provisionerkeys.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func (api *API) deleteProvisionerKey(rw http.ResponseWriter, r *http.Request) {
202202

203203
// @Summary Fetch provisioner key details
204204
// @ID fetch-provisioner-key-details
205-
// @Security CoderSessionToken
205+
// @Security CoderProvisionerKey
206206
// @Produce json
207207
// @Tags Enterprise
208208
// @Param provisionerkey path string true "Provisioner Key"

0 commit comments

Comments
 (0)