mirror of
https://github.com/openziti/zrok.git
synced 2024-11-21 23:53:19 +01:00
grants handler wiring (#744)
This commit is contained in:
parent
6db3e5b877
commit
2f5803a541
@ -56,6 +56,7 @@ func Run(inCfg *config.Config) error {
|
||||
api.AdminCreateFrontendHandler = newCreateFrontendHandler()
|
||||
api.AdminCreateIdentityHandler = newCreateIdentityHandler()
|
||||
api.AdminDeleteFrontendHandler = newDeleteFrontendHandler()
|
||||
api.AdminGrantsHandler = newGrantsHandler()
|
||||
api.AdminInviteTokenGenerateHandler = newInviteTokenGenerateHandler()
|
||||
api.AdminListFrontendsHandler = newListFrontendsHandler()
|
||||
api.AdminUpdateFrontendHandler = newUpdateFrontendHandler()
|
||||
|
22
controller/grants.go
Normal file
22
controller/grants.go
Normal file
@ -0,0 +1,22 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime/middleware"
|
||||
"github.com/openziti/zrok/rest_model_zrok"
|
||||
"github.com/openziti/zrok/rest_server_zrok/operations/admin"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type grantsHandler struct{}
|
||||
|
||||
func newGrantsHandler() *grantsHandler {
|
||||
return &grantsHandler{}
|
||||
}
|
||||
|
||||
func (h *grantsHandler) Handle(params admin.GrantsParams, principal *rest_model_zrok.Principal) middleware.Responder {
|
||||
if !principal.Admin {
|
||||
logrus.Errorf("invalid admin principal")
|
||||
return admin.NewGrantsUnauthorized()
|
||||
}
|
||||
return admin.NewGrantsOK()
|
||||
}
|
Loading…
Reference in New Issue
Block a user