Skip to content

Commit

Permalink
Merge pull request #69 from XenitAB/feature/debug-errors
Browse files Browse the repository at this point in the history
Add error forwarding in the gin middleware
  • Loading branch information
phillebaba committed Sep 28, 2021
2 parents 23224fe + df2412b commit 32ca0fa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions oidcgin/gin.go
Expand Up @@ -28,19 +28,22 @@ func toGinHandler(parseToken oidc.ParseTokenFunc, setters ...options.Option) gin

tokenString, err := oidc.GetTokenString(c.Request.Header.Get, opts.TokenString)
if err != nil {
c.AbortWithStatus(http.StatusBadRequest)
//nolint:errcheck // false positive
c.AbortWithError(http.StatusBadRequest, err)
return
}

token, err := parseToken(ctx, tokenString)
if err != nil {
c.AbortWithStatus(http.StatusUnauthorized)
//nolint:errcheck // false positive
c.AbortWithError(http.StatusUnauthorized, err)
return
}

tokenClaims, err := token.AsMap(ctx)
if err != nil {
c.AbortWithStatus(http.StatusUnauthorized)
//nolint:errcheck // false positive
c.AbortWithError(http.StatusUnauthorized, err)
return
}

Expand Down

0 comments on commit 32ca0fa

Please sign in to comment.