Documentation ¶
Index ¶
- Constants
- func BasicAuthenticate(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
- func CatchInterruption(stop chan bool)
- func EtcdControlMethod(request *restful.Request, response *restful.Response, ...)
- func FormatMethod(request *restful.Request) string
- func HTTPAuthorizationError(writer *restful.Response, err error)
- func HTTPBadRequestError(writer *restful.Response, err error)
- func HTTPInternalError(writer *restful.Response, err error)
- func IdentityFilter(request *restful.Request, response *restful.Response, ...)
- func RunEtcd(stop chan bool, name, directory, clientIP, raftIP, clusterIP string, ...)
- func SetupLog(appModules []string, verbose bool, logfile string) error
- type Controller
- func (c *Controller) CheckMethod(method string) (bool, error)
- func (c *Controller) Delete(path string) (*etcd.Response, error)
- func (c *Controller) DisableMethod(method string) error
- func (c *Controller) EnableMethod(method string) error
- func (c *Controller) Get(path string) ([]*etcd.Response, error)
- func (c *Controller) Ressource(name string) (string, error)
- func (c *Controller) Set(key, value string, ttl uint64) (*etcd.Response, error)
- func (c *Controller) SetUser(user string)
- func (c *Controller) Update(method string) error
- type Router
- type Version
Constants ¶
const ( // Allowed is a macro representing an accessible method Allowed string = "true" // Forbidden is a macro representing an hiden method Forbidden string = "false" )
const ( // MaxMachinesRule restritcs number of deployments allowed // Note that multi-machines deployment counts for one MaxMachinesRule int = 10 )
Variables ¶
This section is empty.
Functions ¶
func BasicAuthenticate ¶
func BasicAuthenticate(req *restful.Request, resp *restful.Response, chain *restful.FilterChain)
BasicAuthenticate is an intermediate step that will check encoded credentials before processing the received request. This function is explicitely used in Register() as a filter in the request pipeline.
func CatchInterruption ¶
func CatchInterruption(stop chan bool)
CatchInterruption handles SIGINT signal to clean the application before exiting. If th stop channel exists it will trigger a signal usuable elsewhere
func EtcdControlMethod ¶
func EtcdControlMethod(request *restful.Request, response *restful.Response, chain *restful.FilterChain)
EtcdControlMethod is a callback part of the request pipeline. It checks in etcd if the received request is allowed for the given user.
func FormatMethod ¶
func FormatMethod(request *restful.Request) string
FormatMethod extracts and concatenate from http request the method and the url, minus the pararmeters. Mostly used further to control the method in the database
func HTTPAuthorizationError ¶
func HTTPAuthorizationError(writer *restful.Response, err error)
HTTPAuthorizationError handles permission failure
func HTTPBadRequestError ¶
func HTTPBadRequestError(writer *restful.Response, err error)
HTTPBadRequestError handles unknown requests
func HTTPInternalError ¶
func HTTPInternalError(writer *restful.Response, err error)
HTTPInternalError handles server errors
func IdentityFilter ¶
func IdentityFilter(request *restful.Request, response *restful.Response, chain *restful.FilterChain)
IdentityFilter does nothing but continuing
func RunEtcd ¶
func RunEtcd(stop chan bool, name, directory, clientIP, raftIP, clusterIP string, force, verbose bool, profile bool)
RunEtcd launchs an http-based key-value storage that holds user and system configuration. Here is spawned a new instance, restricted to relevant command line flags for hivy application.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller knows about rules, constraints and has methods to check them
func NewController ¶
func NewController(user string, debug bool) *Controller
NewController setup debug mode and return an initialized controller
func (*Controller) CheckMethod ¶
func (c *Controller) CheckMethod(method string) (bool, error)
CheckMethod makes sure the given one is like GET/path/to/endpoint (without parameters)
func (*Controller) Delete ¶
func (c *Controller) Delete(path string) (*etcd.Response, error)
Delete wraps go-etcd Delete method
func (*Controller) DisableMethod ¶
func (c *Controller) DisableMethod(method string) error
DisableMethod makes the given method forbidden for the currently controlled user (i.e. c.user)
func (*Controller) EnableMethod ¶
func (c *Controller) EnableMethod(method string) error
EnableMethod makes the given method available for the currently controlled user (i.e. c.user)
func (*Controller) Get ¶
func (c *Controller) Get(path string) ([]*etcd.Response, error)
Get wraps go-etcd Get method
func (*Controller) Ressource ¶
func (c *Controller) Ressource(name string) (string, error)
Ressource the current state or value of the given ressource name Localtion: v1/keys/hivy/security/{user}/ressources/{ressource}
func (*Controller) SetUser ¶
func (c *Controller) SetUser(user string)
SetUser changes the user currently controlled
func (*Controller) Update ¶
func (c *Controller) Update(method string) error
Update actualize states in the database regarding the given request
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
Router is the main functionnal entry point
func NewRouter ¶
NewRouter needs one function handling user/pass authetification, and one function handling method permission for the user who requested it.