15ce12e7b7
* feat(license): add liblicense dep * feat(license): add bolt license service * feat(license): introduce license service * feat(license): validate license before adding * feat(license): aggregate info after changing of licenses * feat(http): implement http handlers * feat(license-management): introduce license service * feat(licenses): introduce empty view * feat(license-management): add datatable * feat(licenses): show license info * fix(license): inject services * feat(licenses): add buttons to buy/renew license * feat(licenses): introduce add license route * feat(licenses): add license form * feat(license): datatable * feat(license): show more details about license * refactor(license): rename components name * feat(licenses): show expiration date * feat(license): introduce init license route * feat(license): validate license * feat(license): save licenses * feat(bouncer): check if license is valid on restricted * feat(bouncer): remove license check on api * feat(home): add node warning * feat(licenses): remove license * feat(licenses): listen to info changes * feat(license): show license expiration message * feat(license): block regular users from licenses view * feat(license): prevent removing of last license * fix(license): show message when failed delete * feat(license): remove trial license when applying oneoff * feat(license): hide the number of nodes for trial * feat(auth): disable login if license is invalid * feat(licenses): add confirmation before removal of license * feat(nodes): count nodes in env * feat(license): show message if nodes exceed allowed * feat(deps): update liblicense * feat(licenses): show validation errors * feat(license): use information panel for node info * fix(license): reload license data on remove * fix(license): always send list of failed keys * fix(license): rename buttons * feat(license): replace icon * feat(license): add link to licenses page in add license * fix(licenses): show green valid icon * fix(licenses): rename expires at * fix(licenses): rename Attach to add * fix(licenses): show license type label * feat(license): aggregate revoked info * chore(deps): update liblicense * fix(license): remove space * fix(sidebar): align icon * fix(license): change info layout * feat(license): aggregate only valid licenses * fix(licenses): move add license to a new line * style(license): remove console * refactor(license): move license line to component * feat(license): check server validation * fix(licenses): check form validation before submit * feat(licenses): send only invalid licenses * fix(license): hide panels when not needed * feat(licnese): receive a single license on init * refactor(header): move header to module * feat(license): move license panel to header * fix(header): set min height * fix(home): show node warning only if subscription * feat(licenses): minor UI updates * feat(licenses): minor UI update * feat(licenses-datatable): add copy button * fix(licenses-datatable): show date without hours * feat(license): show expiration message * fix(users): get user info only on restriced access * fix(license): clear check for single license Co-authored-by: Anthony Lapenna <lapenna.anthony@gmail.com>
44 lines
1.5 KiB
Go
44 lines
1.5 KiB
Go
package auth
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/portainer/api"
|
|
"github.com/portainer/portainer/api/http/proxy"
|
|
"github.com/portainer/portainer/api/http/proxy/factory/kubernetes"
|
|
"github.com/portainer/portainer/api/http/security"
|
|
"github.com/portainer/portainer/api/internal/authorization"
|
|
)
|
|
|
|
// Handler is the HTTP handler used to handle authentication operations.
|
|
type Handler struct {
|
|
*mux.Router
|
|
DataStore portainer.DataStore
|
|
CryptoService portainer.CryptoService
|
|
JWTService portainer.JWTService
|
|
LDAPService portainer.LDAPService
|
|
LicenseService portainer.LicenseService
|
|
OAuthService portainer.OAuthService
|
|
ProxyManager *proxy.Manager
|
|
KubernetesTokenCacheManager *kubernetes.TokenCacheManager
|
|
AuthorizationService *authorization.Service
|
|
}
|
|
|
|
// NewHandler creates a handler to manage authentication operations.
|
|
func NewHandler(bouncer *security.RequestBouncer, rateLimiter *security.RateLimiter) *Handler {
|
|
h := &Handler{
|
|
Router: mux.NewRouter(),
|
|
}
|
|
|
|
h.Handle("/auth/oauth/validate",
|
|
rateLimiter.LimitAccess(bouncer.PublicAccess(httperror.LoggerHandler(h.validateOAuth)))).Methods(http.MethodPost)
|
|
h.Handle("/auth",
|
|
rateLimiter.LimitAccess(bouncer.PublicAccess(httperror.LoggerHandler(h.authenticate)))).Methods(http.MethodPost)
|
|
h.Handle("/auth/logout",
|
|
bouncer.AuthenticatedAccess(httperror.LoggerHandler(h.logout))).Methods(http.MethodPost)
|
|
|
|
return h
|
|
}
|