Documentation ¶
Overview ¶
Package conversions sits between CS3 type definitions and OCS API Responses
Package conversions sits between CS3 type definitions and OCS API Responses
Index ¶
- Constants
- Variables
- func GetPublicShareManager(manager string, m map[string]map[string]interface{}) (publicshare.Manager, error)
- func GetUserManager(manager string, m map[string]map[string]interface{}) (user.Manager, error)
- func LocalGroupIDToString(groupID *grouppb.GroupId) string
- func LocalUserIDToString(userID *userpb.UserId) string
- func ParseTimestamp(timestampString string) (*types.Timestamp, error)
- func UserTypeString(userType userpb.UserType) string
- type ExactMatchesData
- type MatchData
- type MatchValueData
- type Permissions
- type ResourceType
- type Role
- func NewCollaboratorRole() *Role
- func NewDeniedRole() *Role
- func NewEditorRole() *Role
- func NewFileEditorRole() *Role
- func NewLegacyRoleFromOCSPermissions(p Permissions) *Role
- func NewManagerRole() *Role
- func NewReaderRole() *Role
- func NewUnknownRole() *Role
- func NewUploaderRole() *Role
- func NewViewerRole() *Role
- func RoleFromName(name string) *Role
- func RoleFromOCSPermissions(p Permissions) *Role
- func RoleFromResourcePermissions(rp *provider.ResourcePermissions) *Role
- type ShareData
- type ShareType
- type ShareeData
Constants ¶
const ( // RoleViewer grants non-editor role on a resource. RoleViewer = "viewer" // RoleReader grants non-editor role on a resource RoleReader = "reader" // RoleEditor grants editor permission on a resource, including folders. RoleEditor = "editor" // RoleFileEditor grants editor permission on a single file. RoleFileEditor = "file-editor" // RoleCollaborator grants editor+resharing permissions on a resource. RoleCollaborator = "coowner" // RoleUploader grants uploader permission to upload onto a resource. RoleUploader = "uploader" // RoleManager grants manager permissions on a resource. Semantically equivalent to co-owner. RoleManager = "manager" // RoleUnknown is used for unknown roles. RoleUnknown = "unknown" // RoleLegacy provides backwards compatibility. RoleLegacy = "legacy" // RoleDenied grants no permission at all on a resource RoleDenied = "denied" )
Variables ¶
var ( // ErrPermissionNotInRange defines a permission specific error. ErrPermissionNotInRange = fmt.Errorf("the provided permission is not between %d and %d", PermissionInvalid, PermissionAll) )
Functions ¶
func GetPublicShareManager ¶
func GetPublicShareManager(manager string, m map[string]map[string]interface{}) (publicshare.Manager, error)
GetPublicShareManager returns a connection to a public share manager.
func GetUserManager ¶
GetUserManager returns a connection to a user share manager.
func LocalGroupIDToString ¶
LocalGroupIDToString transforms a cs3api group id into an ocs data model without domain name.
func LocalUserIDToString ¶
LocalUserIDToString transforms a cs3api user id into an ocs data model without domain name TODO ocs uses user names ... so an additional lookup is needed. see mapUserIds().
func ParseTimestamp ¶
ParseTimestamp tries to parses the ocs expiry into a CS3 Timestamp.
func UserTypeString ¶
UserTypeString returns human readable strings for various user types.
Types ¶
type ExactMatchesData ¶
type ExactMatchesData struct { Users []*MatchData `json:"users" xml:"users>element"` Groups []*MatchData `json:"groups" xml:"groups>element"` Remotes []*MatchData `json:"remotes" xml:"remotes>element"` }
ExactMatchesData hold exact matches.
type MatchData ¶
type MatchData struct { Label string `json:"label" xml:"label,omitempty"` Value *MatchValueData `json:"value" xml:"value"` }
MatchData describes a single match.
type MatchValueData ¶
type MatchValueData struct {}
MatchValueData holds the type and actual value.
type Permissions ¶
type Permissions uint
Permissions reflects the CRUD permissions used in the OCS sharing API.
const ( // PermissionInvalid grants no permissions on a resource. PermissionInvalid Permissions = 0 // PermissionRead grants read permissions on a resource. PermissionRead Permissions = 1 << (iota - 1) // PermissionWrite grants write permissions on a resource. PermissionWrite // PermissionCreate grants create permissions on a resource. PermissionCreate // PermissionDelete grants delete permissions on a resource. PermissionDelete PermissionShare // PermissionDeny grants permissions to deny access on a resource // The recipient of the resource will then have PermissionNone. PermissionDeny // PermissionNone grants no permissions on a resource. PermissionNone // PermissionMax is to be used within value range checks. PermissionMax Permissions = (1 << (iota - 1)) - 1 // PermissionAll grants all permissions on a resource. PermissionAll = PermissionMax - PermissionNone // PermissionMin is to be used within value range checks. PermissionMin = PermissionRead )
func NewPermissions ¶
func NewPermissions(val int) (Permissions, error)
NewPermissions creates a new Permissions instance. The value must be in the valid range.
func (Permissions) Contain ¶
func (p Permissions) Contain(other Permissions) bool
Contain tests if the permissions contain another one.
type ResourceType ¶
type ResourceType int
ResourceType indicates the OCS type of the resource.
func (ResourceType) String ¶
func (rt ResourceType) String() (s string)
type Role ¶
type Role struct { Name string // contains filtered or unexported fields }
Role is a set of ocs permissions and cs3 resource permissions under a common name.
func NewCollaboratorRole ¶
func NewCollaboratorRole() *Role
NewCollaboratorRole creates a collaborator role.
func NewFileEditorRole ¶
func NewFileEditorRole() *Role
NewFileEditorRole creates a file-editor role.
func NewLegacyRoleFromOCSPermissions ¶
func NewLegacyRoleFromOCSPermissions(p Permissions) *Role
NewLegacyRoleFromOCSPermissions tries to map a legacy combination of ocs permissions to cs3 resource permissions as a legacy role.
func NewUnknownRole ¶
func NewUnknownRole() *Role
NewUnknownRole creates an unknown role. An Unknown role has no permissions over a cs3 resource nor any ocs endpoint.
func RoleFromOCSPermissions ¶
func RoleFromOCSPermissions(p Permissions) *Role
RoleFromOCSPermissions tries to map ocs permissions to a role.
func RoleFromResourcePermissions ¶
func RoleFromResourcePermissions(rp *provider.ResourcePermissions) *Role
RoleFromResourcePermissions tries to map cs3 resource permissions to a role.
func (*Role) CS3ResourcePermissions ¶
func (r *Role) CS3ResourcePermissions() *provider.ResourcePermissions
CS3ResourcePermissions for the role.
func (*Role) OCSPermissions ¶
func (r *Role) OCSPermissions() Permissions
OCSPermissions for the role.
func (*Role) WebDAVPermissions ¶
WebDAVPermissions returns the webdav permissions used in propfinds, eg. "WCKDNVR"
from https://github.com/owncloud/core/blob/10715e2b1c85fc3855a38d2b1fe4426b5e3efbad/apps/dav/lib/Files/PublicFiles/SharedNodeTrait.php#L196-L215 $p = ''; if ($node->isDeletable() && $this->checkSharePermissions(Constants::PERMISSION_DELETE)) { $p .= 'D'; } if ($node->isUpdateable() && $this->checkSharePermissions(Constants::PERMISSION_UPDATE)) { $p .= 'NV'; // Renameable, Moveable } if ($node->getType() === \OCP\Files\FileInfo::TYPE_FILE) { if ($node->isUpdateable() && $this->checkSharePermissions(Constants::PERMISSION_UPDATE)) { $p .= 'W'; } } else { if ($node->isCreatable() && $this->checkSharePermissions(Constants::PERMISSION_CREATE)) { $p .= 'CK'; } }
D = delete NV = update (renameable moveable) W = update (files only) CK = create (folders only) S = Shared R = Shareable M = Mounted Z = Deniable (NEW)
type ShareData ¶
type ShareData struct { string `json:"id" xml:"id"` ShareType ShareType `json:"share_type" xml:"share_type"` UIDOwner string `json:"uid_owner" xml:"uid_owner"` DisplaynameOwner string `json:"displayname_owner" xml:"displayname_owner"` AdditionalInfoOwner string `json:"additional_info_owner" xml:"additional_info_owner"` // TODO(jfd) change the default to read only Permissions Permissions `json:"permissions" xml:"permissions"` STime uint64 `json:"stime" xml:"stime"` Parent string `json:"parent" xml:"parent"` Expiration string `json:"expiration" xml:"expiration"` Token string `json:"token" xml:"token"` UIDFileOwner string `json:"uid_file_owner" xml:"uid_file_owner"` DisplaynameFileOwner string `json:"displayname_file_owner" xml:"displayname_file_owner"` AdditionalInfoFileOwner string `json:"additional_info_file_owner" xml:"additional_info_file_owner"` State int `json:"state" xml:"state"` Path string `json:"path" xml:"path"` ItemType string `json:"item_type" xml:"item_type"` // The RFC2045-compliant mimetype of the file. ItemSource string `json:"item_source" xml:"item_source"` FileSource string `json:"file_source" xml:"file_source"` FileParent string `json:"file_parent" xml:"file_parent"` FileTarget string `json:"file_target" xml:"file_target"` // - a GID (group id) if it is being shared with a group or // - a UID (user id) if the share is shared with a user. // - a password for public links ShareWith string `json:"share_with,omitempty" xml:"share_with,omitempty"` ShareWithDisplayname string `json:"share_with_displayname,omitempty" xml:"share_with_displayname,omitempty"` ShareWithAdditionalInfo string `json:"share_with_additional_info" xml:"share_with_additional_info"` MailSend int `json:"mail_send" xml:"mail_send"` Name string `json:"name" xml:"name"` URL string `json:"url,omitempty" xml:"url,omitempty"` Attributes string `json:"attributes,omitempty" xml:"attributes,omitempty"` // PasswordProtected bool `json:"password_protected,omitempty" xml:"password_protected,omitempty"` Quicklink bool `json:"quicklink,omitempty" xml:"quicklink,omitempty"` Description string `json:"description" xml:"description"` }ID
ShareData represents https://doc.owncloud.com/server/developer_manual/core/ocs-share-api.html#response-attributes-1
func CS3Share2ShareData ¶
CS3Share2ShareData converts a cs3api user share into shareData data model.
func PublicShare2ShareData ¶
PublicShare2ShareData converts a cs3api public share into shareData data model.