From 9a9863d37a95adde97cd82cd7bc8c517c94586b0 Mon Sep 17 00:00:00 2001 From: wass3r <1301201+wass3r@users.noreply.github.com> Date: Sun, 14 Jul 2024 00:17:21 -0500 Subject: [PATCH] fix(swagger/oidc): fix swagger and oidc docs includes the following changes: - oidc and jwks endpoints don't need auth - proper documentation for JWKSet type - fix swagger doc creation --- Makefile | 5 ++--- api/jwks.go | 2 -- api/oi_config.go | 2 -- api/types/oidc.go | 13 ++++++++++--- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 83527e308..c597ea922 100644 --- a/Makefile +++ b/Makefile @@ -281,9 +281,8 @@ spec-install: @echo "### Installing utilities (jq and sponge)" @apt-get update @apt-get install -y jq moreutils - @echo "### Downloading and installing go-swagger" - @curl -o /usr/local/bin/swagger -L "https://github.com/go-swagger/go-swagger/releases/download/v0.30.2/swagger_linux_amd64" - @chmod +x /usr/local/bin/swagger + @echo "### Installing go-swagger" + @go install github.com/go-swagger/go-swagger/cmd/swagger@latest # The `spec-gen` target is intended to create an api-spec # using go-swagger (https://goswagger.io) diff --git a/api/jwks.go b/api/jwks.go index 166ccc15d..fb826048d 100644 --- a/api/jwks.go +++ b/api/jwks.go @@ -21,8 +21,6 @@ import ( // produces: // - application/json // parameters: -// security: -// - ApiKeyAuth: [] // responses: // '200': // description: Successfully retrieved the Vela JWKS diff --git a/api/oi_config.go b/api/oi_config.go index c7f9307b2..6112fd4df 100644 --- a/api/oi_config.go +++ b/api/oi_config.go @@ -22,8 +22,6 @@ import ( // produces: // - application/json // parameters: -// security: -// - ApiKeyAuth: [] // responses: // '200': // description: Successfully retrieved the Vela OpenID Configuration diff --git a/api/types/oidc.go b/api/types/oidc.go index e472c3a42..359178244 100644 --- a/api/types/oidc.go +++ b/api/types/oidc.go @@ -4,7 +4,6 @@ package types import ( "github.com/golang-jwt/jwt/v5" - "github.com/lestrrat-go/jwx/v2/jwk" ) // OpenIDConfig is a struct that represents the OpenID Connect configuration. @@ -37,9 +36,17 @@ type OpenIDClaims struct { jwt.RegisteredClaims } -// JWKSet is a wrapper of lestrrat-go/jwx/jwk.Set for API Swagger gen. +// JWKSet exists solely to provide proper swagger documentation. +// It is not otherwise used in code. // // swagger:model JWKSet type JWKSet struct { - jwk.Set + Keys []JWK `json:"keys"` +} + +type JWK struct { + Kty string `json:"kty"` + Kid string `json:"kid"` + E string `json:"e"` + N string `json:"n"` }