func CookieTokenExtractor(cookieName string) RequestTokenExtractor {
	return func(r *http.Request) (string, error) {
		ck, err := r.Cookie(cookieName)
		if err != nil {
			return "", fmt.Errorf("token cookie not found in request: %v", err)
		}
		if ck.Value == "" {
			return "", errors.New("token cookie found but is empty")
		}
		return ck.Value, nil
	}
}
CookieTokenExtractor returns a RequestTokenExtractor which extracts a token from the named cookie in a request.
package oidc
import (
	"crypto/rand"
	"encoding/base64"
	"errors"
	"fmt"
	"net"
	"net/http"
	"net/url"
	"strings"
	"time"
	"github.com/coreos/go-oidc/jose"
)
type RequestTokenExtractor func(r *http.Request) (string, error)
func ExtractBearerToken(r *http.Request) (string, error) {
	ah := r.Header.Get("Authorization")
	if ah == "" {
		return "", errors.New("missing Authorization header")
	}
	if len(ah) <= 6 || strings.ToUpper(ah[0:6]) != "BEARER" {
		return "", errors.New("should be a bearer token")
	}
	val := ah[7:]
	if len(val) == 0 {
		return "", errors.New("bearer token is empty")
	}
	return val, nil
}