permission

package
v3.2.0+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2019 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package permission handles API calls and persistence for spaces. Spaces in Documize contain documents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanChangeDocument

func CanChangeDocument(ctx domain.RequestContext, s store.Store, documentID string) bool

CanChangeDocument returns if the clinet has permission to change a given document.

func CanDeleteDocument

func CanDeleteDocument(ctx domain.RequestContext, s store.Store, documentID string) bool

CanDeleteDocument returns if the clinet has permission to change a given document.

func CanManageVersion added in v1.59.0

func CanManageVersion(ctx domain.RequestContext, s store.Store, spaceID string) bool

CanManageVersion returns if the user has permission to manage versions in space.

func CanUploadDocument

func CanUploadDocument(ctx domain.RequestContext, s store.Store, spaceID string) bool

CanUploadDocument returns if the client has permission to upload documents to the given space.

func CanViewDocument

func CanViewDocument(ctx domain.RequestContext, s store.Store, documentID string) bool

CanViewDocument returns if the client has permission to view a given document.

func CanViewDrafts added in v1.59.0

func CanViewDrafts(ctx domain.RequestContext, s store.Store, spaceID string) bool

CanViewDrafts returns if the user has permission to view drafts in space.

func CanViewSpace

func CanViewSpace(ctx domain.RequestContext, s store.Store, spaceID string) bool

CanViewSpace returns if the user has permission to view the given spaceID.

func CanViewSpaceDocument

func CanViewSpaceDocument(ctx domain.RequestContext, s store.Store, labelID string) bool

CanViewSpaceDocument returns if the user has permission to view a document within the specified folder.

func CheckPermission added in v1.66.0

func CheckPermission(ctx domain.RequestContext, s store.Store, spaceID string, userID string, actions ...pm.Action) bool

CheckPermission returns if specified user can perform specified actions.

func GetUsersWithDocumentPermission added in v1.63.0

func GetUsersWithDocumentPermission(ctx domain.RequestContext, s store.Store, spaceID, documentID string, permissionRequired pm.Action) (users []u.User, err error)

GetUsersWithDocumentPermission returns list of users who have specified document permission in given space

func HasPermission

func HasPermission(ctx domain.RequestContext, s store.Store, spaceID string, actions ...pm.Action) bool

HasPermission returns if current user can perform specified actions.

Types

type Handler

type Handler struct {
	Runtime *env.Runtime
	Store   *store.Store
}

Handler contains the runtime information such as logging and database.

func (*Handler) GetCategoryPermissions

func (h *Handler) GetCategoryPermissions(w http.ResponseWriter, r *http.Request)

GetCategoryPermissions returns user permissions for given category.

func (*Handler) GetCategoryViewers

func (h *Handler) GetCategoryViewers(w http.ResponseWriter, r *http.Request)

GetCategoryViewers returns user permissions for given category.

func (*Handler) GetDocumentPermissions added in v1.56.0

func (h *Handler) GetDocumentPermissions(w http.ResponseWriter, r *http.Request)

GetDocumentPermissions returns permissions for all users for given document.

func (*Handler) GetSpacePermissions

func (h *Handler) GetSpacePermissions(w http.ResponseWriter, r *http.Request)

GetSpacePermissions returns permissions for all users for given space.

func (*Handler) GetUserDocumentPermissions added in v1.56.0

func (h *Handler) GetUserDocumentPermissions(w http.ResponseWriter, r *http.Request)

GetUserDocumentPermissions returns permissions for the requested document, for current user.

func (*Handler) GetUserSpacePermissions

func (h *Handler) GetUserSpacePermissions(w http.ResponseWriter, r *http.Request)

GetUserSpacePermissions returns permissions for the requested space, for current user.

func (*Handler) SetCategoryPermissions

func (h *Handler) SetCategoryPermissions(w http.ResponseWriter, r *http.Request)

SetCategoryPermissions persists specified category permissions

func (*Handler) SetDocumentPermissions added in v1.56.0

func (h *Handler) SetDocumentPermissions(w http.ResponseWriter, r *http.Request)

SetDocumentPermissions persists specified document permissions These permissions override document permissions

func (*Handler) SetSpacePermissions

func (h *Handler) SetSpacePermissions(w http.ResponseWriter, r *http.Request)

SetSpacePermissions persists specified space permissions

type Store added in v1.71.0

type Store struct {
	store.Context
	store.PermissionStorer
}

Store provides data access to user permission information.

func (Store) AddPermission added in v1.71.0

func (s Store) AddPermission(ctx domain.RequestContext, r permission.Permission) (err error)

AddPermission inserts the given record into the permisssion table.

func (Store) AddPermissions added in v1.71.0

func (s Store) AddPermissions(ctx domain.RequestContext, r permission.Permission, actions ...permission.Action) (err error)

AddPermissions inserts records into permission database table, one per action.

func (Store) DeleteCategoryPermissions added in v1.71.0

func (s Store) DeleteCategoryPermissions(ctx domain.RequestContext, categoryID string) (rows int64, err error)

DeleteCategoryPermissions removes records from dmz_permissions table for given category ID.

func (Store) DeleteDocumentPermissions added in v1.71.0

func (s Store) DeleteDocumentPermissions(ctx domain.RequestContext, documentID string) (rows int64, err error)

DeleteDocumentPermissions removes records from dmz_permissions table for given document.

func (Store) DeleteGroupPermissions added in v1.71.0

func (s Store) DeleteGroupPermissions(ctx domain.RequestContext, groupID string) (rows int64, err error)

DeleteGroupPermissions removes all roles for the specified group

func (Store) DeleteSpaceCategoryPermissions added in v1.71.0

func (s Store) DeleteSpaceCategoryPermissions(ctx domain.RequestContext, spaceID string) (rows int64, err error)

DeleteSpaceCategoryPermissions removes all category permission for for given space.

func (Store) DeleteSpacePermissions added in v1.71.0

func (s Store) DeleteSpacePermissions(ctx domain.RequestContext, spaceID string) (rows int64, err error)

DeleteSpacePermissions removes records from dmz_permissions table for given space ID.

func (Store) DeleteUserPermissions added in v1.71.0

func (s Store) DeleteUserPermissions(ctx domain.RequestContext, userID string) (rows int64, err error)

DeleteUserPermissions removes all roles for the specified user, for the specified space.

func (Store) DeleteUserSpacePermissions added in v1.71.0

func (s Store) DeleteUserSpacePermissions(ctx domain.RequestContext, spaceID, userID string) (rows int64, err error)

DeleteUserSpacePermissions removes all roles for the specified user, for the specified space.

func (Store) GetCategoryPermissions added in v1.71.0

func (s Store) GetCategoryPermissions(ctx domain.RequestContext, catID string) (r []permission.Permission, err error)

GetCategoryPermissions returns category permissions for all users.

func (Store) GetCategoryUsers added in v1.71.0

func (s Store) GetCategoryUsers(ctx domain.RequestContext, catID string) (u []user.User, err error)

GetCategoryUsers returns space permissions for all users.

func (Store) GetDocumentPermissions added in v1.71.0

func (s Store) GetDocumentPermissions(ctx domain.RequestContext, documentID string) (r []permission.Permission, err error)

GetDocumentPermissions returns documents permissions for all users. We do not filter by userID because we return permissions for all users.

func (Store) GetSpacePermissions added in v1.71.0

func (s Store) GetSpacePermissions(ctx domain.RequestContext, spaceID string) (r []permission.Permission, err error)

GetSpacePermissions returns space permissions for all users. We do not filter by userID because we return permissions for all users.

func (Store) GetSpacePermissionsForUser added in v1.71.0

func (s Store) GetSpacePermissionsForUser(ctx domain.RequestContext, spaceID, userID string) (r []permission.Permission, err error)

GetSpacePermissionsForUser returns space permissions for specified user.

func (Store) GetUserCategoryPermissions added in v1.71.0

func (s Store) GetUserCategoryPermissions(ctx domain.RequestContext, userID string) (r []permission.Permission, err error)

GetUserCategoryPermissions returns category permissions for given user.

func (Store) GetUserDocumentPermissions added in v1.71.0

func (s Store) GetUserDocumentPermissions(ctx domain.RequestContext, documentID string) (r []permission.Permission, err error)

GetUserDocumentPermissions returns document permissions for user. Context is used to for user ID.

func (Store) GetUserSpacePermissions added in v1.71.0

func (s Store) GetUserSpacePermissions(ctx domain.RequestContext, spaceID string) (r []permission.Permission, err error)

GetUserSpacePermissions returns space permissions for user. Context is used to for userID because must match by userID or everyone ID of 0.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL