8dba19694a
* refactor(rbac): move client extension code * feat(app): remove checks for extension * feat(rbac): remove checks for extensions * feat(extensions): remove reference to rbac extensions * feat(roles): add changes from codebase before removal of rbac * refactor(security): remove rbac service * refactor(security): use AdminAccess as an alias * fix(access): rename policies type * style(security): add comment about Aliasing AdminAccess to RestrictedAccess * feat(bolt): add auth migration from ce to ee * feat(stacks): use authorized access to stop/start stacks * fix(bolt): supply right params to migrator * feat(rbac): get authorization on client side
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package endpoints
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
"github.com/portainer/portainer/api"
|
|
"github.com/portainer/portainer/api/bolt/errors"
|
|
)
|
|
|
|
// GET request on /api/endpoints/:id
|
|
func (handler *Handler) endpointInspect(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
endpointID, err := request.RetrieveNumericRouteVariableValue(r, "id")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "Invalid endpoint identifier route variable", err}
|
|
}
|
|
|
|
endpoint, err := handler.DataStore.Endpoint().Endpoint(portainer.EndpointID(endpointID))
|
|
if err == errors.ErrObjectNotFound {
|
|
return &httperror.HandlerError{http.StatusNotFound, "Unable to find an endpoint with the specified identifier inside the database", err}
|
|
} else if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Unable to find an endpoint with the specified identifier inside the database", err}
|
|
}
|
|
|
|
err = handler.requestBouncer.AuthorizedEndpointOperation(r, endpoint, false)
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusForbidden, "Permission denied to access endpoint", err}
|
|
}
|
|
|
|
hideFields(endpoint)
|
|
|
|
return response.JSON(w, endpoint)
|
|
}
|