github XenitAB/go-oidc-middleware v0.0.8

latest releases: oidcgin/v0.0.32, oidcechojwt/v0.0.32, oidchttp/v0.0.32...
2 years ago

Changes:

  • Move defaults to options package (#32)
  • Change echojwt from using jwt.Token to map[string]interface{} (#33)

Breaking change:

oidcechojwt now returns a map[string]interface{} instead of jwt.Token.

Previously, you had to use the following:

func newClaimsHandler(c echo.Context) error {
	token, ok := c.Get("user").(jwt.Token)
	if !ok {
		return echo.NewHTTPError(http.StatusUnauthorized, "invalid token")
	}

	claims, err := token.AsMap(c.Request().Context())
	if err != nil {
		return echo.NewHTTPError(http.StatusUnauthorized, "invalid token")
	}

	return c.JSON(http.StatusOK, claims)
}

Now you you instead get the claims directly:

func newClaimsHandler(c echo.Context) error {
	claims, ok := c.Get("user").(map[string]interface{})
	if !ok {
		return echo.NewHTTPError(http.StatusUnauthorized, "invalid token")
	}

	return c.JSON(http.StatusOK, claims)
}

Don't miss a new go-oidc-middleware release

NewReleases is sending notifications on new releases.