grants handler wiring (#744)

This commit is contained in:
Michael Quigley 2024-09-04 16:18:20 -04:00
parent 6db3e5b877
commit 2f5803a541
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 23 additions and 0 deletions

View File

@ -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
View 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()
}