github XenitAB/go-oidc-middleware v0.0.11

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

Changes

This PR adds the ability to manipulate a token string after it has been extracted from a header using options.WithTokenStringPostExtractionFn.

Example:

oidcHandler := oidcgin.New(
	options.WithIssuer(cfg.Issuer),
	options.WithFallbackSignatureAlgorithm(cfg.FallbackSignatureAlgorithm),
	options.WithRequiredClaims(map[string]interface{}{
		"cid": cfg.ClientID,
	}),
	options.WithTokenString(
		options.WithTokenStringHeaderName("Authorization"),
		options.WithTokenStringTokenPrefix("Bearer "),
	),
	options.WithTokenString(
		options.WithTokenStringHeaderName("Sec-WebSocket-Protocol"),
		options.WithTokenStringTokenPrefix("base64url.bearer.authorization.k8s.io."),
		options.WithTokenStringListSeparator(","),
		options.WithTokenStringPostExtractionFn(func(s string) (string, error) {
			bytes, err := base64.RawStdEncoding.DecodeString(s)
			if err != nil {
				return "", err
			}

			return string(bytes), nil
		}),
	),
)

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

NewReleases is sending notifications on new releases.