MCPcopy Create free account
hub / github.com/clouditor/clouditor / parseToken

Function parseToken

server/auth_middleware.go:145–164  ·  view source on GitHub ↗
(token string, authConfig *AuthConfig)

Source from the content-addressed store, hash-verified

143}
144
145func parseToken(token string, authConfig *AuthConfig) (jwt.Claims, error) {
146 var parsedToken *jwt.Token
147 var err error
148
149 // Use JWKS, if enabled
150 if authConfig.useJWKS {
151 parsedToken, err = jwt.ParseWithClaims(token, &OpenIDConnectClaim{}, authConfig.jwks.Keyfunc)
152 } else {
153 // Otherwise, we will use the supplied public key
154 parsedToken, err = jwt.ParseWithClaims(token, &OpenIDConnectClaim{}, func(t *jwt.Token) (interface{}, error) {
155 return authConfig.publicKey, nil
156 })
157 }
158
159 if err != nil {
160 return nil, fmt.Errorf("could not validate JWT: %w", err)
161 }
162
163 return parsedToken.Claims, nil
164}

Callers 1

AuthFuncMethod · 0.85

Calls 1

ErrorfMethod · 0.80

Tested by

no test coverage detected