-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathjwks.go
50 lines (40 loc) · 1.08 KB
/
jwks.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// SPDX-License-Identifier: Apache-2.0
package api
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/sirupsen/logrus"
"github.com/go-vela/server/database"
"github.com/go-vela/server/util"
)
// swagger:operation GET /_services/token/.well-known/jwks token GetJWKS
//
// Get the JWKS for the Vela OIDC service
//
// ---
// produces:
// - application/json
// parameters:
// responses:
// '200':
// description: Successfully retrieved the Vela JWKS
// schema:
// "$ref": "#/definitions/JWKSet"
// '500':
// description: Unexpected server error
// schema:
// "$ref": "#/definitions/Error"
// GetJWKS represents the API handler for requests to public keys in the Vela OpenID service.
func GetJWKS(c *gin.Context) {
l := c.MustGet("logger").(*logrus.Entry)
l.Debug("reading JWKS")
// retrieve JWKs from the database
keys, err := database.FromContext(c).ListJWKs(c)
if err != nil {
retErr := fmt.Errorf("unable to get key set: %w", err)
util.HandleError(c, http.StatusInternalServerError, retErr)
return
}
c.JSON(http.StatusOK, keys)
}