func (m AuthMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request, _ caddyhttp.Handler) error {
	rr := requests.NewRequest()
	rr.ID = GetRequestID(r)
	return m.Portal.ServeHTTP(r.Context(), w, r, rr)
}
ServeHTTP authorizes access based on the presense and content of JWT token.
package portal
import (
	"net/http"
	"github.com/caddyserver/caddy/v2"
	"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
	"github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile"
	"github.com/caddyserver/caddy/v2/modules/caddyhttp"
	"github.com/greenpau/caddy-auth-portal/pkg/authn"
	"github.com/greenpau/go-identity/pkg/requests"
	"github.com/satori/go.uuid"
)
func init() {
	caddy.RegisterModule(AuthMiddleware{})
}
type AuthMiddleware struct {
	Portal *authn.Authenticator `json:"authp,omitempty"`
}
func (AuthMiddleware) CaddyModule() caddy.ModuleInfo {
	return caddy.ModuleInfo{
		ID:  "http.handlers.authp",
		New: func() caddy.Module { return new(AuthMiddleware) },
	}
}
func (m *AuthMiddleware) Provision(ctx caddy.Context) error {
	m.Portal.SetLogger(ctx.Logger(m))
	return m.Portal.Provision()
}
func (m *AuthMiddleware) UnmarshalCaddyfile(d *caddyfile.Dispenser) (err error) {
	portal, err := parseCaddyfileAuthenticator(httpcaddyfile.Helper{Dispenser: d})
	if err != nil {
		return err
	}
	m.Portal = portal
	return nil
}
func (m *AuthMiddleware) Validate() error {
	return m.Portal.Validate()
}