share

package
v4.4.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const PasswordComplexitySuffix = "#$!Az1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	common.RuntimeHolder
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, checker ContextEditableChecker) *Client

NewClient creates a new share client. Leave checker nil to use default implementation (returning always true)

func (*Client) AclsToCellAcls

func (sc *Client) AclsToCellAcls(ctx context.Context, acls []*idm.ACL) map[string]*rest.CellAcl

AclsToCellAcls Rewrites a flat list of ACLs to a structured map of CellAcls (more easily usable by clients).

func (*Client) CellById added in v4.2.0

func (sc *Client) CellById(ctx context.Context, wsUuid string, owner *idm.User) (*rest.Cell, error)

CellById finds a Cell by its Uuid

func (*Client) CellsForNode added in v4.2.0

func (sc *Client) CellsForNode(ctx context.Context, node *tree.Node, owner *idm.User) (ll []*rest.Cell, e error)

CellsForNode loads existing Cells attached to a given node (and owned by passed user)

func (*Client) CheckCellOptionsAgainstConfigs

func (sc *Client) CheckCellOptionsAgainstConfigs(ctx context.Context, cell *rest.Cell) error

CheckCellOptionsAgainstConfigs loads specific share configurations from ACLs and checks that current cell complies with these.

func (*Client) CheckLinkOptionsAgainstConfigs

func (sc *Client) CheckLinkOptionsAgainstConfigs(ctx context.Context, link *rest.ShareLink, wss []*tree.WorkspaceRelativePath, files, folders bool) (PluginOptions, error)

CheckLinkOptionsAgainstConfigs loads specific share configurations from ACLs and checks that current link complies with these.

func (*Client) CheckLinkRootNodes

func (sc *Client) CheckLinkRootNodes(ctx context.Context, link *rest.ShareLink) (workspaces []*tree.WorkspaceRelativePath, files, folders bool, e error)

CheckLinkRootNodes loads the root nodes and check if one of the is readonly. If so, check that link permissions do not try to set the Upload mode.

func (*Client) ClearLostHiddenUsers

func (sc *Client) ClearLostHiddenUsers(ctx context.Context) error

ClearLostHiddenUsers makes sure that hidden users that are not linked to any existing link are removed. This is used during a migration to fix the missing users deletion prior to v2.0.0

func (*Client) CommonAclsForWorkspace

func (sc *Client) CommonAclsForWorkspace(ctx context.Context, workspaceId string) (result []*idm.ACL, detectedRoots []string, err error)

CommonAclsForWorkspace makes successive calls to ACL service to get all ACLs for a given workspace.

func (*Client) ComputeTargetAcls

func (sc *Client) ComputeTargetAcls(ctx context.Context, ownerUser *idm.User, cell *rest.Cell, workspaceId string, readonly bool, parentPolicy string) ([]*idm.ACL, error)

ComputeTargetAcls create ACL objects that should be applied for this cell.

func (*Client) DefaultOptions added in v4.2.0

func (sc *Client) DefaultOptions() PluginOptions

DefaultOptions loads the plugin default options, without further context-based filtering

func (*Client) DeleteCell added in v4.2.0

func (sc *Client) DeleteCell(ctx context.Context, id string, ownerLogin string) error

DeleteCell deletes a Cell by its ID

func (*Client) DeleteHashDocument

func (sc *Client) DeleteHashDocument(ctx context.Context, shareId string) error

DeleteHashDocument removes link data from the storage.

func (*Client) DeleteHiddenUser

func (sc *Client) DeleteHiddenUser(ctx context.Context, link *rest.ShareLink) error

DeleteHiddenUser removes hidden user associated with this link

func (sc *Client) DeleteLink(ctx context.Context, id string) error

DeleteLink disable an existing ShareLink and remove associated resources

func (*Client) DeleteLinkWorkspace added in v4.2.0

func (sc *Client) DeleteLinkWorkspace(ctx context.Context, workspaceId string) error

DeleteLinkWorkspace wraps DeleteWorkspace to remove unnecessary parameters

func (*Client) DeleteRootNodeRecursively

func (sc *Client) DeleteRootNodeRecursively(ctx context.Context, ownerName string, roomNode *tree.Node) error

DeleteRootNodeRecursively loads all children of a root node and delete them, including the .pydio hidden files when they are folders.

func (*Client) DeleteWorkspace

func (sc *Client) DeleteWorkspace(ctx context.Context, ownerLogin string, scope idm.WorkspaceScope, workspaceId string) error

DeleteWorkspace deletes a workspace and associated policies and ACLs. It also deletes the room node if necessary.

func (*Client) DetectInheritedPolicy

func (sc *Client) DetectInheritedPolicy(ctx context.Context, roots []*tree.Node, loadedParents []*tree.WorkspaceRelativePath) (string, error)

func (*Client) DiffAcls

func (sc *Client) DiffAcls(ctx context.Context, initial []*idm.ACL, newOnes []*idm.ACL) (add []*idm.ACL, remove []*idm.ACL)

DiffAcls compares to slices of ACLs on their RoleID and Action and returns slices of Acls to add and to remove.

func (*Client) DiffReadRoles

func (sc *Client) DiffReadRoles(ctx context.Context, initial []*idm.ACL, newOnes []*idm.ACL) (add []string, remove []string)

DiffReadRoles detects the roles that have been globally added or removed, whatever the node.

func (*Client) GetCellWorkspace added in v4.2.0

func (sc *Client) GetCellWorkspace(ctx context.Context, wsUuid string) (*idm.Workspace, error)

GetCellWorkspace is a shortcut for GetOrCreateWorkspace but for retrieval only

func (*Client) GetLinkWorkspace added in v4.2.0

func (sc *Client) GetLinkWorkspace(ctx context.Context, wsUuid string) (*idm.Workspace, error)

GetLinkWorkspace is a shortcut for GetOrCreateWorkspace but for retrieval only

func (*Client) GetOrCreateHiddenUser

func (sc *Client) GetOrCreateHiddenUser(ctx context.Context, ownerUser *idm.User, link *rest.ShareLink, passwordEnabled bool, updatePassword string, passwordHashed bool) (user *idm.User, err error)

GetOrCreateHiddenUser will load or create a user to create a ShareLink with.

func (*Client) GetOrCreateWorkspace

func (sc *Client) GetOrCreateWorkspace(ctx context.Context, ownerUser *idm.User, wsUuid string, scope idm.WorkspaceScope, label string, refLabel string, description string, updateIfNeeded bool) (*idm.Workspace, bool, error)

GetOrCreateWorkspace finds a workspace by its Uuid or creates it with the current user ResourcePolicies if it does not already exist.

func (*Client) GetTemplateACLsForMinisite

func (sc *Client) GetTemplateACLsForMinisite(ctx context.Context, roleId string, perms []rest.ShareLinkAccessType, aclClient idm.ACLServiceClient) (acls []*idm.ACL, err error)

GetTemplateACLsForMinisite loads actions and parameter acls from specific template roles.

func (*Client) InheritPolicies

func (sc *Client) InheritPolicies(ctx context.Context, policyName string, read, write bool) (string, error)

InheritPolicies find possible SecurityPolicy currently implied and compute a new one based on it.

func (*Client) InterpretInheritedPolicy

func (sc *Client) InterpretInheritedPolicy(ctx context.Context, name string) (read, write bool, e error)

InterpretInheritedPolicy translates a SecurityPolicy to read/write permissions for user readability

func (*Client) LinkById added in v4.2.0

func (sc *Client) LinkById(ctx context.Context, wsUuid string) (*rest.ShareLink, error)

LinkById loads a ShareLink by Uuid

func (*Client) LinksForNode added in v4.2.0

func (sc *Client) LinksForNode(ctx context.Context, node *tree.Node, owner *idm.User) (ll []*rest.ShareLink, e error)

LinksForNode loads existing links for a give node

func (*Client) ListSharedResources added in v4.2.0

func (sc *Client) ListSharedResources(ctx context.Context, subject string, scope idm.WorkspaceScope, ownedBy bool, p resources.ResourceProviderHandler) ([]*SharedResource, error)

ListSharedResources lists all links and cells Owned by a given user

func (*Client) LoadAdminRootNodes added in v4.2.0

func (sc *Client) LoadAdminRootNodes(ctx context.Context, detectedRoots []string) (rootNodes map[string]*tree.Node)

LoadAdminRootNodes find actual nodes in the tree, and enrich their metadata if they appear in many workspaces for the current user.

func (*Client) LoadCellAclsObjects

func (sc *Client) LoadCellAclsObjects(ctx context.Context, roomAcls map[string]*rest.CellAcl) error

LoadCellAclsObjects loads associated users / groups / roles based on the role Ids of the acls.

func (*Client) LoadDetectedRootNodes

func (sc *Client) LoadDetectedRootNodes(ctx context.Context, detectedRoots []string, accessList *permissions.AccessList) (rootNodes map[string]*tree.Node)

LoadDetectedRootNodes find actual nodes in the tree, and enrich their metadata if they appear in many workspaces for the current user.

func (*Client) LoadHashDocumentData

func (sc *Client) LoadHashDocumentData(ctx context.Context, shareLink *rest.ShareLink, acls []*idm.ACL) error

LoadHashDocumentData loads link data from the storage (currently Docstore) by link Uuid.

func (*Client) OwnerResourcePolicies

func (sc *Client) OwnerResourcePolicies(ctx context.Context, ownerUser *idm.User, resourceId string) []*service.ResourcePolicy

OwnerResourcePolicies produces a set of policies given ownership to current context user, read/write to current context user, and write access to profile:admin (can be useful for admin).

func (*Client) ParseRootNodes

func (sc *Client) ParseRootNodes(ctx context.Context, cell *rest.Cell, createEmpty bool) (bool, error)

ParseRootNodes reads the request property to either create a new node using the "rooms" Virtual node, or just verify that the root nodes are not empty.

func (*Client) RootsParentWorkspaces

func (sc *Client) RootsParentWorkspaces(ctx context.Context, rr []*tree.Node) (ww []*tree.WorkspaceRelativePath, e error)

RootsParentWorkspaces reads parents and find the root node of the workspace

func (*Client) SearchHashDocumentForUser

func (sc *Client) SearchHashDocumentForUser(ctx context.Context, userLogin string) (*docstore.ShareDocument, error)

SearchHashDocumentForUser searches the DocStore to find documents that have either PRELOG_USER or PRESET_LOGIN with the passed userLogin value.

func (*Client) SharesForNode added in v4.2.0

func (sc *Client) SharesForNode(ctx context.Context, node *tree.Node, contextOwner *idm.User, scopes ...idm.WorkspaceScope) ([]*idm.Workspace, error)

SharesForNode finds all active workspaces (Links or Cells) for a given node+owner combination

func (*Client) StoreHashDocument

func (sc *Client) StoreHashDocument(ctx context.Context, ownerUser *idm.User, link *rest.ShareLink, updateHash ...string) error

StoreHashDocument sends link data to the storage backend, currently the Docstore service.

func (*Client) UpdateACLsForHiddenUser

func (sc *Client) UpdateACLsForHiddenUser(ctx context.Context, roleId string, workspaceId string, rootNodes []*tree.Node, permissions []rest.ShareLinkAccessType, parentPolicy string, update bool) error

UpdateACLsForHiddenUser deletes and replaces access ACLs for a hidden user.

func (*Client) UpdatePoliciesFromAcls

func (sc *Client) UpdatePoliciesFromAcls(ctx context.Context, workspace *idm.Workspace, initial []*idm.ACL, target []*idm.ACL) bool

UpdatePoliciesFromAcls recomputes the required policies from acl changes.

func (*Client) UpsertCell added in v4.2.0

func (sc *Client) UpsertCell(ctx context.Context, cell *rest.Cell, ownerUser *idm.User, hasReadonly bool, parentPolicy string) (*rest.Cell, error)

UpsertCell creates or update an existing cell with specific ACLs

func (sc *Client) UpsertLink(ctx context.Context, link *rest.ShareLink, linkOptions LinkOptioner, ownerUser *idm.User, parentPolicy string, options PluginOptions) (*rest.ShareLink, error)

UpsertLink creates or updates a ShareLink. ownerUser is required to apply correct permissions to the new/updated link The plugin options can be user-permissions-based otherwise use client.DefaultOptions()

func (*Client) WorkspaceToCellObject

func (sc *Client) WorkspaceToCellObject(ctx context.Context, workspace *idm.Workspace, accessList *permissions.AccessList) (*rest.Cell, error)

WorkspaceToCellObject rewrites a workspace to a Cell object by reloading its ACLs.

func (*Client) WorkspaceToShareLinkObject

func (sc *Client) WorkspaceToShareLinkObject(ctx context.Context, workspace *idm.Workspace) (*rest.ShareLink, error)

WorkspaceToShareLinkObject converts a workspace to a rest.ShareLink model.

type ContextEditableChecker

type ContextEditableChecker interface {
	IsContextEditable(ctx context.Context, resourceId string, policies []*service2.ResourcePolicy) bool
}

type EmptyContextChecker added in v4.2.0

type EmptyContextChecker struct{}

func (*EmptyContextChecker) IsContextEditable added in v4.2.0

func (*EmptyContextChecker) IsContextEditable(ctx context.Context, resourceId string, policies []*service2.ResourcePolicy) bool

type LinkOptioner added in v4.2.0

type LinkOptioner interface {
	GetPasswordEnabled() bool
	GetCreatePassword() string
	GetUpdatePassword() string
	GetUpdateCustomHash() string
}

type PluginOptions

type PluginOptions struct {
	MaxExpiration      int
	CellsMaxExpiration int
	MaxDownloads       int
	HashMinLength      int
	HashEditable       bool
	ShareForcePassword bool
	// contains filtered or unexported fields
}

type SharedResource added in v4.2.0

type SharedResource struct {
	Node       *tree.Node
	Workspaces []*idm.Workspace
}

Directories

Path Synopsis
Package rest exposes a REST API to manage shared rooms.
Package rest exposes a REST API to manage shared rooms.

Jump to

Keyboard shortcuts

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