{"modulePath":"github.com/koderover/zadig","version":"v1.18.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package handler\n\n## Functions\n\n```go\nfunc CheckPermissionGivenByCollaborationMode(uid, projectKey, resource, action string) (bool, error)\n```\nCheckPermissionGivenByCollaborationMode checks if a user is permitted to perform specific action in a given project. Although collaboration mode is used to control the action to specific resources, under some circumstances, there are leaks/designs that allows user with resource permission not related to the corresponding resource to access. e.g. ListTest API will allow anyone with edit workflow permission to call it. In this case, we need to check if the permission is granted by collaboration mode. AVOID USING THIS !!! FIXME: This function shouldn't exist. The only reason it exists is the incompetent of the system designer.\n\n```go\nfunc GetCollaborationModePermission(uid, projectKey, resource, resourceName, action string) (bool, error)\n```\n\n```go\nfunc GetResourcesInHeader(c *gin.Context) ([]string, bool)\n```\n\n```go\nfunc InsertDetailedOperationLog(c *gin.Context, username, productName, scene, method, function, detail, requestBody string, logger *zap.SugaredLogger, targets ...string)\n```\n\n```go\nfunc InsertOperationLog(c *gin.Context, username, productName, method, function, detail, requestBody string, logger *zap.SugaredLogger)\n```\nInsertOperationLog 插入操作日志\n\n```go\nfunc JSONResponse(c *gin.Context, ctx *Context)\n```\n\n```go\nfunc ListAuthorizedProjects(uid string) ([]string, bool, error)\n```\n\n```go\nfunc ListAuthorizedProjectsByResourceAndVerb(uid, resource, verb string) ([]string, bool, error)\n```\n\n```go\nfunc ListAuthorizedWorkflows(uid, projectKey string) (authorizedWorkflow, authorizedWorkflowV4 []string, enableFilter bool, err error)\n```\n\n```go\nfunc ListCollaborationEnvironmentsPermission(uid, projectKey string) (authorizedEnv *types.CollaborationEnvPermission, err error)\n```\n\n```go\nfunc Stream(c *gin.Context, p producer, log *zap.SugaredLogger)\n```\n\n## Types\n\n```go\ntype Context struct {\n\tLogger       *zap.SugaredLogger\n\tUnAuthorized bool\n\tErr          error\n\tResp         interface{}\n\tAccount      string\n\tUserName     string\n\tUserID       string\n\tIdentityType string\n\tRequestID    string\n\tResources    *user.AuthorizedResources\n}\n```\nContext struct\n\n```go\nfunc NewContext(c *gin.Context) *Context\n```\nNewContext returns a context without user authorization info. TODO: We need to implement a \\`context.Context\\` that conforms to the golang standard library. After Jul.10 2023, this function should only be used when no authorization info is required. If authorization info is required, use \\`NewContextWithAuthorization\\` instead.\n\n```go\nfunc NewContextWithAuthorization(c *gin.Context) (*Context, error)\n```\nNewContextWithAuthorization returns a context with user authorization info. This function should only be called when one need authorization information for api caller.\n\n```go\ntype FederatedClaims struct {\n\tConnectorId string `json:\"connector_id\"`\n\tUserId      string `json:\"user_id\"`\n}\n```\n\n","path":"github.com/koderover/zadig/pkg/shared/handler","name":"handler","synopsis":"","isRedistributable":true}
