func NewOauthAuth(cfg *config.Config, authPath string) (a *OidcAuth, err error) {
	a = &OidcAuth{}
	a.cfg = cfg
	a.loginURL = cfg.URL + path.Join(authPath, "login")
	a.redirectURL = cfg.URL + path.Join(authPath, "callback")
	a.store = sessions.NewCookieStore(cfg.CookieSecret)
	provider, err := oidc.NewProvider(context.Background(), cfg.OidcIssuer)
	if err != nil {
		return nil, fmt.Errorf("unable to connect to oidc provider: %s", err)
	}
	a.oauthConfig = &oauth2.Config{
		ClientID:     cfg.OidcClientID,
		ClientSecret: cfg.OidcClientSecret,
		RedirectURL:  a.redirectURL,
		Endpoint:     provider.Endpoint(),
		Scopes:       []string{oidc.ScopeOpenID},
	}
	oidcConfig := &oidc.Config{ClientID: a.oauthConfig.ClientID}
	a.verifier = provider.Verifier(oidcConfig)
	a.authMap = &sync.Map{}
	tick := time.NewTicker(10 * time.Minute)
	go func() {
		for range tick.C {
			a.authMap.Range(func(key, value interface{}) (cont bool) {
				cont = true
				token, ok := value.(*oauth2.Token)
				if !ok {
					log.WithError(fmt.Errorf(
						"%T is not a *Token", value),
					).Error("unable to cleanup token map")
					return
				}
				if time.Since(token.Expiry) > time.Hour {
					log.Debugf("cleaning orphan token for %v", key)
					a.authMap.Delete(key)
				}
				return true
			})
		}
	}()
	return
}
NewOauthAuth creates a new Auth
package auth
import (
	"context"
	"crypto/rand"
	"encoding/base64"
	"fmt"
	"net/http"
	"path"
	"strings"
	"sync"
	"time"
	"github.com/coreos/go-oidc"
	"github.com/gorilla/sessions"
	log "github.com/sirupsen/logrus"
	"golang.org/x/oauth2"
	"github.com/bitsbeats/prometheus-acls/internal/config"
	"github.com/bitsbeats/prometheus-acls/internal/core"
	"github.com/bitsbeats/prometheus-acls/internal/prom"
)
type (
	OidcAuth struct {
		loginURL    string
		redirectURL string
		cfg         *config.Config
		store       *sessions.CookieStore
		oauthConfig *oauth2.Config
		verifier    *oidc.IDTokenVerifier
		authMap     *sync.Map
	}
)