Documentation ¶
Index ¶
- Variables
- func DecodeBase64(cx *goweb.Context, id string) (return_id string)
- func GetAclQuery(u *user.User) (query bson.M)
- func GetAuthorizedUser(cx *goweb.Context) (u *user.User, done bool)
- func GetClientGroup(cx *goweb.Context) (cg *core.ClientGroup, done bool)
- func LogRequest(req *http.Request)
- func ParseMultipartForm(r *http.Request) (params map[string]string, files core.FormFiles, err error)
- func PrintLogo()
- func QueryParseDefaultOptions(cx *goweb.Context) (opt *core.DefaultQueryOptions, err error)
- func RawDir(cx *goweb.Context)
- func ResourceDescription(cx *goweb.Context)
- func RespondPrivateEnvInHeader(cx *goweb.Context, Envs map[string]string) (err error)
- func RespondTokenInHeader(cx *goweb.Context, token string)
- func SiteDir(cx *goweb.Context)
- type AwfController
- type ClientController
- func (cr *ClientController) Create(cx *goweb.Context)
- func (cr *ClientController) Delete(id string, cx *goweb.Context)
- func (cr *ClientController) DeleteMany(cx *goweb.Context)
- func (cr *ClientController) Options(cx *goweb.Context)
- func (cr *ClientController) Read(id string, cx *goweb.Context)
- func (cr *ClientController) ReadMany(cx *goweb.Context)
- func (cr *ClientController) Update(id string, cx *goweb.Context)
- func (cr *ClientController) UpdateMany(cx *goweb.Context)
- type ClientGroupController
- func (cr *ClientGroupController) CreateWithId(name string, cx *goweb.Context)
- func (cr *ClientGroupController) Delete(id string, cx *goweb.Context)
- func (cr *ClientGroupController) Options(cx *goweb.Context)
- func (cr *ClientGroupController) Read(id string, cx *goweb.Context)
- func (cr *ClientGroupController) ReadMany(cx *goweb.Context)
- type JobController
- func (cr *JobController) Create(cx *goweb.Context)
- func (cr *JobController) Delete(id string, cx *goweb.Context)
- func (cr *JobController) DeleteMany(cx *goweb.Context)
- func (cr *JobController) Options(cx *goweb.Context)
- func (cr *JobController) Read(id string, cx *goweb.Context)
- func (cr *JobController) ReadMany(cx *goweb.Context)
- func (cr *JobController) Update(id string, cx *goweb.Context)
- func (cr *JobController) UpdateMany(cx *goweb.Context)
- type LoggerController
- func (cr *LoggerController) Create(cx *goweb.Context)
- func (cr *LoggerController) Delete(id string, cx *goweb.Context)
- func (cr *LoggerController) DeleteMany(cx *goweb.Context)
- func (cr *LoggerController) Options(cx *goweb.Context)
- func (cr *LoggerController) Read(id string, cx *goweb.Context)
- func (cr *LoggerController) ReadMany(cx *goweb.Context)
- func (cr *LoggerController) Update(id string, cx *goweb.Context)
- func (cr *LoggerController) UpdateMany(cx *goweb.Context)
- type ProxyController
- type Query
- type QueueController
- func (cr *QueueController) Create(cx *goweb.Context)
- func (cr *QueueController) Delete(id string, cx *goweb.Context)
- func (cr *QueueController) DeleteMany(cx *goweb.Context)
- func (cr *QueueController) Options(cx *goweb.Context)
- func (cr *QueueController) Read(id string, cx *goweb.Context)
- func (cr *QueueController) ReadMany(cx *goweb.Context)
- func (cr *QueueController) Update(id string, cx *goweb.Context)
- func (cr *QueueController) UpdateMany(cx *goweb.Context)
- type ServerController
- type StandardResponse
- type WorkController
- type WorkflowInstancesController
Constants ¶
This section is empty.
Variables ¶
var ClientGroupAclController goweb.ControllerFunc = func(cx *goweb.Context) { LogRequest(cx.Request) if cx.Request.Method == "OPTIONS" { cx.RespondWithOK() return } u, err := request.Authenticate(cx.Request) if err != nil && err.Error() != e.NoAuth { cx.RespondWithErrorMessage(err.Error(), http.StatusUnauthorized) return } if u == nil { if conf.ANON_CG_READ == true { u = &user.User{Uuid: "public"} } else { cx.RespondWithErrorMessage(e.NoAuth, http.StatusUnauthorized) return } } cgid := cx.PathParams["cgid"] cg, err := core.LoadClientGroup(cgid) if err != nil { if err == mgo.ErrNotFound { cx.RespondWithNotFound() return } else { cx.RespondWithErrorMessage("clientgroup not found: "+cgid, http.StatusBadRequest) return } } rights := cg.Acl.Check(u.Uuid) if cg.Acl.Owner != u.Uuid && u.Admin == false && cg.Acl.Owner != "public" && rights["read"] == false { cx.RespondWithErrorMessage(e.UnAuth, http.StatusUnauthorized) return } if cx.Request.Method == "GET" { cx.RespondWithData(cg.Acl) } else { cx.RespondWithErrorMessage("This request type is not implemented.", http.StatusNotImplemented) } return }
GET: /cgroup/{cgid}/acl/ (only OPTIONS and GET are supported here)
var ClientGroupAclControllerTyped goweb.ControllerFunc = func(cx *goweb.Context) { LogRequest(cx.Request) if cx.Request.Method == "OPTIONS" { cx.RespondWithOK() return } u, err := request.Authenticate(cx.Request) if err != nil { cx.RespondWithErrorMessage(err.Error(), http.StatusUnauthorized) return } cgid := cx.PathParams["cgid"] rtype := cx.PathParams["type"] rmeth := cx.Request.Method if !validClientGroupAclTypes[rtype] { cx.RespondWithErrorMessage("Invalid acl type", http.StatusBadRequest) return } cg, err := core.LoadClientGroup(cgid) if err != nil { if err == mgo.ErrNotFound { cx.RespondWithNotFound() } else { cx.RespondWithErrorMessage("clientgroup not found: "+cgid, http.StatusBadRequest) } return } ids, err := parseClientGroupAclRequestTyped(cx) if err != nil { cx.RespondWithErrorMessage(err.Error(), http.StatusBadRequest) return } if cg.Acl.Owner != u.Uuid && u.Admin == false { if rmeth == "DELETE" { if len(ids) != 1 || (len(ids) == 1 && ids[0] != u.Uuid) { cx.RespondWithErrorMessage("Non-owners of clientgroups can delete one and only user from the ACLs (themselves)", http.StatusBadRequest) return } if rtype == "owner" { cx.RespondWithErrorMessage("Deleting ownership is not a supported request type.", http.StatusBadRequest) return } else if rtype == "all" { cg.Acl.UnSet(ids[0], map[string]bool{"read": true, "write": true, "delete": true, "execute": true}) } else { cg.Acl.UnSet(ids[0], map[string]bool{rtype: true}) } cg.Save() cx.RespondWithData(cg.Acl) return } cx.RespondWithErrorMessage("Users that are not clientgroup owners can only delete themselves from ACLs.", http.StatusBadRequest) return } if rmeth == "GET" { cx.RespondWithData(cg.Acl) return } else if rmeth == "POST" || rmeth == "PUT" { if rtype == "owner" { if len(ids) == 1 { cg.Acl.SetOwner(ids[0]) } else { cx.RespondWithErrorMessage("Clientgroups must have one owner.", http.StatusBadRequest) return } } else if rtype == "all" { for _, i := range ids { cg.Acl.Set(i, map[string]bool{"read": true, "write": true, "delete": true, "execute": true}) } } else if rtype == "public_read" { cg.Acl.Set("public", map[string]bool{"read": true}) } else if rtype == "public_write" { cg.Acl.Set("public", map[string]bool{"write": true}) } else if rtype == "public_delete" { cg.Acl.Set("public", map[string]bool{"delete": true}) } else if rtype == "public_execute" { cg.Acl.Set("public", map[string]bool{"execute": true}) } else if rtype == "public_all" { cg.Acl.Set("public", map[string]bool{"read": true, "write": true, "delete": true, "execute": true}) } else { for _, i := range ids { cg.Acl.Set(i, map[string]bool{rtype: true}) } } cg.Save() cx.RespondWithData(cg.Acl) return } else if rmeth == "DELETE" { if rtype == "owner" { cx.RespondWithErrorMessage("Deleting ownership is not a supported request type.", http.StatusBadRequest) return } else if rtype == "all" { for _, i := range ids { cg.Acl.UnSet(i, map[string]bool{"read": true, "write": true, "delete": true, "execute": true}) } } else if rtype == "public_read" { cg.Acl.UnSet("public", map[string]bool{"read": true}) } else if rtype == "public_write" { cg.Acl.UnSet("public", map[string]bool{"write": true}) } else if rtype == "public_delete" { cg.Acl.UnSet("public", map[string]bool{"delete": true}) } else if rtype == "public_execute" { cg.Acl.UnSet("public", map[string]bool{"execute": true}) } else if rtype == "public_all" { cg.Acl.UnSet("public", map[string]bool{"read": true, "write": true, "delete": true, "execute": true}) } else { for _, i := range ids { cg.Acl.UnSet(i, map[string]bool{rtype: true}) } } cg.Save() cx.RespondWithData(cg.Acl) return } else { cx.RespondWithErrorMessage("This request type is not implemented.", http.StatusNotImplemented) return } }
GET, POST, PUT, DELETE, OPTIONS: /cgroup/{cgid}/acl/{type}
var ClientGroupTokenController goweb.ControllerFunc = func(cx *goweb.Context) { LogRequest(cx.Request) if cx.Request.Method == "OPTIONS" { cx.RespondWithOK() return } u, err := request.Authenticate(cx.Request) if err != nil && err.Error() != e.NoAuth { cx.RespondWithErrorMessage(err.Error(), http.StatusUnauthorized) return } if u == nil { if conf.ANON_CG_WRITE == true { u = &user.User{Uuid: "public"} } else { cx.RespondWithErrorMessage(e.UnAuth, http.StatusUnauthorized) return } } cgid := cx.PathParams["cgid"] cg, err := core.LoadClientGroup(cgid) if err != nil { if err == mgo.ErrNotFound { cx.RespondWithNotFound() } else { cx.RespondWithErrorMessage("clientgroup id not found:"+cgid, http.StatusBadRequest) } return } rights := cg.Acl.Check(u.Uuid) public_rights := cg.Acl.Check("public") if (u.Uuid != "public" && (cg.Acl.Owner == u.Uuid || rights["write"] == true || u.Admin == true || public_rights["write"] == true)) || (u.Uuid == "public" && conf.ANON_CG_WRITE == true && public_rights["write"] == true) { switch cx.Request.Method { case "PUT": if cg.Token != "" { cx.RespondWithErrorMessage("Clientgroup has existing token. This must be deleted before a new token can be generated.", http.StatusBadRequest) return } cg.SetToken() if err = cg.Save(); err != nil { cx.RespondWithErrorMessage("Could not save clientgroup.", http.StatusInternalServerError) return } cx.RespondWithData(cg) return case "DELETE": cg.Token = "" if err = cg.Save(); err != nil { cx.RespondWithErrorMessage("Could not save clientgroup.", http.StatusInternalServerError) return } cx.RespondWithData(cg) return default: cx.RespondWithError(http.StatusNotImplemented) return } } cx.RespondWithErrorMessage(e.UnAuth, http.StatusUnauthorized) return }
GET, POST, PUT, DELETE, OPTIONS: /cgroup/{cgid}/token/ (only OPTIONS, PUT and DELETE are implemented)
var JobAclController goweb.ControllerFunc = func(cx *goweb.Context) { LogRequest(cx.Request) if cx.Request.Method == "OPTIONS" { cx.RespondWithOK() return } u, err := request.Authenticate(cx.Request) if err != nil && err.Error() != e.NoAuth { cx.RespondWithErrorMessage(err.Error(), http.StatusUnauthorized) return } if u == nil { if conf.ANON_READ == true { u = &user.User{Uuid: "public"} } else { cx.RespondWithErrorMessage(e.NoAuth, http.StatusUnauthorized) return } } jid := cx.PathParams["jid"] acl, err := core.DBGetJobAcl(jid) if err != nil { if err == mgo.ErrNotFound { cx.RespondWithNotFound() } else { cx.RespondWithErrorMessage("job not found: "+jid+" "+err.Error(), http.StatusBadRequest) } return } rights := acl.Check(u.Uuid) if acl.Owner != u.Uuid && u.Admin == false && acl.Owner != "public" && rights["read"] == false { cx.RespondWithErrorMessage(e.UnAuth, http.StatusUnauthorized) return } if cx.Request.Method == "GET" { cx.RespondWithData(acl) } else { cx.RespondWithErrorMessage("This request type is not implemented.", http.StatusNotImplemented) } return }
GET: /job/{jid}/acl/ (only OPTIONS and GET are supported here)
var JobAclControllerTyped goweb.ControllerFunc = func(cx *goweb.Context) { LogRequest(cx.Request) if cx.Request.Method == "OPTIONS" { cx.RespondWithOK() return } u, err := request.Authenticate(cx.Request) if err != nil { cx.RespondWithErrorMessage(err.Error(), http.StatusUnauthorized) return } jid := cx.PathParams["jid"] rtype := cx.PathParams["type"] rmeth := cx.Request.Method if !validJobAclTypes[rtype] { cx.RespondWithErrorMessage("Invalid acl type", http.StatusBadRequest) return } acl, err := core.DBGetJobAcl(jid) if err != nil { if err == mgo.ErrNotFound { cx.RespondWithNotFound() } else { cx.RespondWithErrorMessage("job not found: "+jid+" "+err.Error(), http.StatusBadRequest) } return } ids, err := parseJobAclRequestTyped(cx) if err != nil { cx.RespondWithErrorMessage(err.Error(), http.StatusBadRequest) return } if acl.Owner != u.Uuid && u.Admin == false { if rmeth == "DELETE" { if len(ids) != 1 || (len(ids) == 1 && ids[0] != u.Uuid) { cx.RespondWithErrorMessage("Non-owners of a job can delete one and only user from the ACLs (themselves).", http.StatusBadRequest) return } if rtype == "owner" { cx.RespondWithErrorMessage("Deleting job ownership is not a supported request type.", http.StatusBadRequest) return } if rtype == "all" { acl.UnSet(ids[0], map[string]bool{"read": true, "write": true, "delete": true}) } else { acl.UnSet(ids[0], map[string]bool{rtype: true}) } err = core.DbUpdateJobField(jid, "acl", acl) if err != nil { cx.RespondWithErrorMessage("acl update error: "+jid, http.StatusBadRequest) return } cx.RespondWithData(acl) return } cx.RespondWithErrorMessage("Users that are not job owners can only delete themselves from ACLs.", http.StatusBadRequest) return } if rmeth == "GET" { cx.RespondWithData(acl) return } else if rmeth == "POST" || rmeth == "PUT" { if rtype == "owner" { if len(ids) == 1 { acl.SetOwner(ids[0]) } else { cx.RespondWithErrorMessage("Jobs must have one owner.", http.StatusBadRequest) return } } else if rtype == "all" { for _, i := range ids { acl.Set(i, map[string]bool{"read": true, "write": true, "delete": true}) } } else if rtype == "public_read" { acl.Set("public", map[string]bool{"read": true}) } else if rtype == "public_write" { acl.Set("public", map[string]bool{"write": true}) } else if rtype == "public_delete" { acl.Set("public", map[string]bool{"delete": true}) } else if rtype == "public_all" { acl.Set("public", map[string]bool{"read": true, "write": true, "delete": true}) } else { for _, i := range ids { acl.Set(i, map[string]bool{rtype: true}) } } err = core.DbUpdateJobField(jid, "acl", acl) if err != nil { cx.RespondWithErrorMessage("acl update error: "+jid, http.StatusBadRequest) return } cx.RespondWithData(acl) return } else if rmeth == "DELETE" { if rtype == "owner" { cx.RespondWithErrorMessage("Deleting ownership is not a supported request type.", http.StatusBadRequest) return } else if rtype == "all" { for _, i := range ids { acl.UnSet(i, map[string]bool{"read": true, "write": true, "delete": true}) } } else if rtype == "public_read" { acl.UnSet("public", map[string]bool{"read": true}) } else if rtype == "public_write" { acl.UnSet("public", map[string]bool{"write": true}) } else if rtype == "public_delete" { acl.UnSet("public", map[string]bool{"delete": true}) } else if rtype == "public_all" { acl.UnSet("public", map[string]bool{"read": true, "write": true, "delete": true}) } else { for _, i := range ids { acl.UnSet(i, map[string]bool{rtype: true}) } } err = core.DbUpdateJobField(jid, "acl", acl) if err != nil { cx.RespondWithErrorMessage("acl update error: "+jid, http.StatusBadRequest) return } cx.RespondWithData(acl) return } else { cx.RespondWithErrorMessage("This request type is not implemented.", http.StatusNotImplemented) return } }
GET, POST, PUT, DELETE, OPTIONS: /job/{jid}/acl/{type}
Functions ¶
func DecodeBase64 ¶ added in v0.9.62
func GetAuthorizedUser ¶ added in v0.9.62
func GetClientGroup ¶ added in v0.9.62
func GetClientGroup(cx *goweb.Context) (cg *core.ClientGroup, done bool)
func LogRequest ¶
func ParseMultipartForm ¶
func ParseMultipartForm(r *http.Request) (params map[string]string, files core.FormFiles, err error)
helper function for create & update
func QueryParseDefaultOptions ¶
func QueryParseDefaultOptions(cx *goweb.Context) (opt *core.DefaultQueryOptions, err error)
func ResourceDescription ¶
func RespondPrivateEnvInHeader ¶ added in v0.9.3
func RespondTokenInHeader ¶
Types ¶
type AwfController ¶
type AwfController struct{}
func (*AwfController) Read ¶
func (cr *AwfController) Read(id string, cx *goweb.Context)
GET: /awf/{name} get a workflow by name, read-only
func (*AwfController) ReadMany ¶
func (cr *AwfController) ReadMany(cx *goweb.Context)
GET: /awf get all loaded workflows
type ClientController ¶
type ClientController struct{}
func (*ClientController) Create ¶
func (cr *ClientController) Create(cx *goweb.Context)
POST: /client - register a new client
func (*ClientController) Delete ¶
func (cr *ClientController) Delete(id string, cx *goweb.Context)
DELETE: /client/{id}
func (*ClientController) DeleteMany ¶
func (cr *ClientController) DeleteMany(cx *goweb.Context)
DELETE: /client
func (*ClientController) Options ¶
func (cr *ClientController) Options(cx *goweb.Context)
OPTIONS: /client
func (*ClientController) Read ¶
func (cr *ClientController) Read(id string, cx *goweb.Context)
GET: /client/{id}
func (*ClientController) ReadMany ¶
func (cr *ClientController) ReadMany(cx *goweb.Context)
GET: /client
func (*ClientController) Update ¶
func (cr *ClientController) Update(id string, cx *goweb.Context)
PUT: /client/{id} -> status update
func (*ClientController) UpdateMany ¶
func (cr *ClientController) UpdateMany(cx *goweb.Context)
PUT: /client
type ClientGroupController ¶ added in v0.9.3
type ClientGroupController struct{}
func (*ClientGroupController) CreateWithId ¶ added in v0.9.3
func (cr *ClientGroupController) CreateWithId(name string, cx *goweb.Context)
POST: /cgroup/{name}
func (*ClientGroupController) Delete ¶ added in v0.9.3
func (cr *ClientGroupController) Delete(id string, cx *goweb.Context)
DELETE: /cgroup/{id}
func (*ClientGroupController) Options ¶ added in v0.9.3
func (cr *ClientGroupController) Options(cx *goweb.Context)
OPTIONS: /cgroup
func (*ClientGroupController) Read ¶ added in v0.9.3
func (cr *ClientGroupController) Read(id string, cx *goweb.Context)
GET: /cgroup/{id}
func (*ClientGroupController) ReadMany ¶ added in v0.9.3
func (cr *ClientGroupController) ReadMany(cx *goweb.Context)
GET: /cgroup
type JobController ¶
type JobController struct{}
func (*JobController) Delete ¶
func (cr *JobController) Delete(id string, cx *goweb.Context)
DELETE: /job/{id}
func (*JobController) DeleteMany ¶
func (cr *JobController) DeleteMany(cx *goweb.Context)
DELETE: /job?suspend, /job?zombie
func (*JobController) Read ¶
func (cr *JobController) Read(id string, cx *goweb.Context)
GET: /job/{id}
func (*JobController) ReadMany ¶
func (cr *JobController) ReadMany(cx *goweb.Context)
GET: /job To do: - Iterate job queries
type LoggerController ¶ added in v0.9.30
type LoggerController struct{}
func (*LoggerController) Create ¶ added in v0.9.30
func (cr *LoggerController) Create(cx *goweb.Context)
POST: /logger
func (*LoggerController) Delete ¶ added in v0.9.30
func (cr *LoggerController) Delete(id string, cx *goweb.Context)
DELETE: /logger/{id}
func (*LoggerController) DeleteMany ¶ added in v0.9.30
func (cr *LoggerController) DeleteMany(cx *goweb.Context)
DELETE: /logger
func (*LoggerController) Options ¶ added in v0.9.30
func (cr *LoggerController) Options(cx *goweb.Context)
OPTIONS: /logger
func (*LoggerController) Read ¶ added in v0.9.30
func (cr *LoggerController) Read(id string, cx *goweb.Context)
GET: /logger/{id}
func (*LoggerController) ReadMany ¶ added in v0.9.30
func (cr *LoggerController) ReadMany(cx *goweb.Context)
GET: /logger
func (*LoggerController) Update ¶ added in v0.9.30
func (cr *LoggerController) Update(id string, cx *goweb.Context)
PUT: /logger/{id}
func (*LoggerController) UpdateMany ¶ added in v0.9.30
func (cr *LoggerController) UpdateMany(cx *goweb.Context)
PUT: /logger
type ProxyController ¶
type ProxyController struct { Client *ClientController Work *WorkController }
func NewProxyController ¶
func NewProxyController() *ProxyController
type QueueController ¶
type QueueController struct{}
func (*QueueController) Delete ¶
func (cr *QueueController) Delete(id string, cx *goweb.Context)
DELETE: /queue/{id}
func (*QueueController) DeleteMany ¶
func (cr *QueueController) DeleteMany(cx *goweb.Context)
DELETE: /queue
func (*QueueController) Options ¶
func (cr *QueueController) Options(cx *goweb.Context)
OPTIONS: /queue
func (*QueueController) Read ¶
func (cr *QueueController) Read(id string, cx *goweb.Context)
GET: /queue/{id}
func (*QueueController) ReadMany ¶
func (cr *QueueController) ReadMany(cx *goweb.Context)
GET: /queue get status from queue manager
func (*QueueController) Update ¶
func (cr *QueueController) Update(id string, cx *goweb.Context)
PUT: /queue/{id} -> status update
func (*QueueController) UpdateMany ¶
func (cr *QueueController) UpdateMany(cx *goweb.Context)
PUT: /queue
type ServerController ¶
type ServerController struct { Awf *AwfController Client *ClientController ClientGroup *ClientGroupController ClientGroupAcl map[string]goweb.ControllerFunc ClientGroupToken goweb.ControllerFunc Job *JobController JobAcl map[string]goweb.ControllerFunc Logger *LoggerController Queue *QueueController Work *WorkController WorkflowInstances *WorkflowInstancesController }
func NewServerController ¶
func NewServerController() *ServerController
type StandardResponse ¶ added in v0.9.33
type WorkController ¶
type WorkController struct{}
func (*WorkController) Options ¶
func (cr *WorkController) Options(cx *goweb.Context)
OPTIONS: /work
func (*WorkController) Read ¶
func (cr *WorkController) Read(id string, cx *goweb.Context)
GET: /work/{id} get a workunit by id, read-only
func (*WorkController) ReadMany ¶
func (cr *WorkController) ReadMany(cx *goweb.Context)
GET: /work checkout a workunit with earliest submission time to-do: to support more options for workunit checkout
type WorkflowInstancesController ¶
type WorkflowInstancesController struct{}
func (*WorkflowInstancesController) Read ¶
func (cr *WorkflowInstancesController) Read(id string, cx *goweb.Context)
GET: /workflow_instances/{id}
func (*WorkflowInstancesController) ReadMany ¶
func (cr *WorkflowInstancesController) ReadMany(cx *goweb.Context)
GET: /workflow_instances/