community: github.com/documize/community/domain/permission Index | Files

package permission

import "github.com/documize/community/domain/permission"

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

Index

Package Files

endpoint.go permission.go store.go

func CanChangeDocument Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

HasPermission returns if current user can perform specified actions.

type Handler Uses

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

Handler contains the runtime information such as logging and database.

func (*Handler) GetCategoryPermissions Uses

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

GetCategoryPermissions returns user permissions for given category.

func (*Handler) GetCategoryViewers Uses

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

GetCategoryViewers returns user permissions for given category.

func (*Handler) GetDocumentPermissions Uses

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

GetDocumentPermissions returns permissions for all users for given document.

func (*Handler) GetSpacePermissions Uses

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

GetSpacePermissions returns permissions for all users for given space.

func (*Handler) GetUserDocumentPermissions Uses

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

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

func (*Handler) GetUserSpacePermissions Uses

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

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

func (*Handler) SetCategoryPermissions Uses

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

SetCategoryPermissions persists specified category permissions

func (*Handler) SetDocumentPermissions Uses

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

SetDocumentPermissions persists specified document permissions These permissions override document permissions

func (*Handler) SetSpacePermissions Uses

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

SetSpacePermissions persists specified space permissions

type Store Uses

type Store struct {
    store.Context
    store.PermissionStorer
}

Store provides data access to user permission information.

func (Store) AddPermission Uses

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

AddPermission inserts the given record into the permisssion table.

func (Store) AddPermissions Uses

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 Uses

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 Uses

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 Uses

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

DeleteGroupPermissions removes all roles for the specified group

func (Store) DeleteSpaceCategoryPermissions Uses

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 Uses

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 Uses

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 Uses

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 Uses

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

GetCategoryPermissions returns category permissions for all users.

func (Store) GetCategoryUsers Uses

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

GetCategoryUsers returns space permissions for all users.

func (Store) GetDocumentPermissions Uses

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 Uses

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 Uses

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 Uses

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

GetUserCategoryPermissions returns category permissions for given user.

func (Store) GetUserDocumentPermissions Uses

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 Uses

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.

Package permission imports 20 packages (graph) and is imported by 12 packages. Updated 2019-08-30. Refresh now. Tools for package owners.