func NewServer(c *component.Component, store Store, config Config, cspFunc func(config *Config, nonce string) string) (Server, error) {
	s := &server{
		c:           c,
		config:      config,
		store:       store,
		session:     session.Session{Store: store},
		generateCSP: cspFunc,
	}
	if s.config.Mount == "" {
		s.config.Mount = s.config.UI.MountPath()
	}
	s.osinConfig = &osin.ServerConfig{
		AuthorizationExpiration: int32((5 * time.Minute).Seconds()),
		AccessExpiration:        int32(time.Hour.Seconds()),
		TokenType:               "bearer",
		AllowedAuthorizeTypes: osin.AllowedAuthorizeType{
			osin.CODE,
		},
		AllowedAccessTypes: osin.AllowedAccessType{
			osin.AUTHORIZATION_CODE,
			osin.REFRESH_TOKEN,
			osin.PASSWORD,
		},
		ErrorStatusCode:           http.StatusBadRequest,
		AllowClientSecretInParams: true,
		RedirectUriSeparator:      redirectURISeparator,
		RetainTokenAfterRefresh:   false,
	}
	return s, nil
}
NewServer returns a new OAuth server on top of the given store.
package oauth
import (
	"context"
	"net/http"
	"strings"
	"time"
	echo "github.com/labstack/echo/v4"
	"github.com/openshift/osin"
	"go.thethings.network/lorawan-stack/v3/pkg/account/session"
	"go.thethings.network/lorawan-stack/v3/pkg/component"
	"go.thethings.network/lorawan-stack/v3/pkg/errors"
	web_errors "go.thethings.network/lorawan-stack/v3/pkg/errors/web"
	"go.thethings.network/lorawan-stack/v3/pkg/identityserver/store"
	"go.thethings.network/lorawan-stack/v3/pkg/log"
	"go.thethings.network/lorawan-stack/v3/pkg/ratelimit"
	"go.thethings.network/lorawan-stack/v3/pkg/web"
	"go.thethings.network/lorawan-stack/v3/pkg/web/middleware"
	"go.thethings.network/lorawan-stack/v3/pkg/webui"
)
type Server interface {
	web.Registerer
	Authorize(authorizePage echo.HandlerFunc) echo.HandlerFunc
	Token(c echo.Context) error
}
type server struct {
	c           *component.Component
	config      Config
	osinConfig  *osin.ServerConfig
	store       Store
	session     session.Session
	generateCSP func(config *Config, nonce string) string
}
type Store interface {
	store.UserStore
	store.UserSessionStore
	store.ClientStore
	store.OAuthStore
}