Skip to content

Commit

Permalink
fix(swagger/oidc): fix swagger and oidc docs (#1159)
Browse files Browse the repository at this point in the history
* 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

* fix the fix

* validate fix

* pin to version

---------

Co-authored-by: David May <49894298+wass3rw3rk@users.noreply.github.com>
Co-authored-by: Easton Crupper <65553218+ecrupper@users.noreply.github.com>
  • Loading branch information
3 people authored Sep 6, 2024
1 parent 372a430 commit e0c2f7e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: create spec
run: |
sudo make spec-install
make spec-install
make spec
- name: upload spec
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ jobs:
- name: validate spec
run: |
sudo make spec-install
make spec-install
make spec
9 changes: 4 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -279,11 +279,10 @@ spec-install:
$(if $(shell command -v apt-get 2> /dev/null),,$(error 'apt-get' not found - install jq, sponge, and go-swagger manually))
@echo
@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
@sudo apt-get update
@sudo apt-get install -y jq moreutils
@echo "### Installing go-swagger"
@go install github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0

# The `spec-gen` target is intended to create an api-spec
# using go-swagger (https://goswagger.io)
Expand Down
2 changes: 0 additions & 2 deletions api/jwks.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import (
// produces:
// - application/json
// parameters:
// security:
// - ApiKeyAuth: []
// responses:
// '200':
// description: Successfully retrieved the Vela JWKS
Expand Down
2 changes: 0 additions & 2 deletions api/oi_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (
// produces:
// - application/json
// parameters:
// security:
// - ApiKeyAuth: []
// responses:
// '200':
// description: Successfully retrieved the Vela OpenID Configuration
Expand Down
13 changes: 10 additions & 3 deletions api/types/oidc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -40,9 +39,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"`
}

0 comments on commit e0c2f7e

Please sign in to comment.