nextcloud

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package nextcloud verifies a clientID and clientSecret against a Nextcloud backend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNextcloudServerMock

func GetNextcloudServerMock(called *[]string) http.Handler

GetNextcloudServerMock returns a handler that pretends to be a remote Nextcloud server.

func New

func New(ctx context.Context, m map[string]interface{}) (share.Repository, error)

New returns a share manager implementation that verifies against a Nextcloud backend.

func TestingHTTPClient

func TestingHTTPClient(handler http.Handler) (*http.Client, func())

TestingHTTPClient thanks to https://itnext.io/how-to-stub-requests-to-remote-hosts-with-go-6c2c1db32bf2 Ideally, this function would live in tests/helpers, but if we put it there, it gets excluded by .dockerignore, and the Docker build fails (see https://github.com/cs3org/reva/issues/1999) So putting it here for now - open to suggestions if someone knows a better way to inject this.

Types

type Action

type Action struct {
	// contains filtered or unexported fields
}

Action describes a REST request to forward to the Nextcloud backend.

type EfssGrantee added in v1.28.0

type EfssGrantee struct {
	ID *provider.Grantee_UserId `json:"id"`
}

EfssGrantee is a helper struct to JSON-unmarshal a Grantee Grantees are hard to unmarshal, so unmarshalling into a map[string]interface{} first, see also https://github.com/pondersource/sciencemesh-nextcloud/issues/27

type EfssShare added in v1.28.0

type EfssShare struct {
	ID         *ocm.ShareId `json:"id"    validate:"required"`
	Name       string       `json:"name"  validate:"required"`
	Token      string       `json:"token"`
	ResourceID struct {
		OpaqueID string `json:"opaque_id" validate:"required"`
	} `json:"resource_id" validate:"required"`
	ResourceType  string `json:"resource_type"   validate:"omitempty"`
	RemoteShareID string `json:"remote_share_id" validate:"required"`
	Protocols     struct {
		WebDAV struct {
			URI         string `json:"uri"`
			Permissions int    `json:"permissions" validate:"required"`
		} `json:"webdav" validate:"required"`
		WebApp struct {
			URITemplate string `json:"uri_template"`
			ViewMode    string `json:"view_mode"`
		} `json:"webapp" validate:"omitempty"`
		DataTx struct {
			SourceURI string `json:"source_uri"`
			Size      int    `json:"size"`
		} `json:"transfer" validate:"omitempty"`
	} `json:"protocols" validate:"required"`
	Grantee *userpb.User       `json:"grantee" validate:"required"`
	Owner   *userpb.User       `json:"owner"   validate:"required"`
	Creator *userpb.User       `json:"creator" validate:"required"`
	Ctime   *typespb.Timestamp `json:"ctime"   validate:"required"`
	Mtime   *typespb.Timestamp `json:"mtime"   validate:"required"`
}

EfssShare is a representation of a federated share as exchanged with the EFSS. It includes all needed fields to represent a received federated share as well, see below.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is the Nextcloud-based implementation of the share.Repository interface see https://github.com/cs3org/reva/blob/v1.13.0/pkg/ocm/share/share.go#L30-L57

func NewShareManager

func NewShareManager(c *ShareManagerConfig) (*Manager, error)

NewShareManager returns a new Nextcloud-based ShareManager.

func (*Manager) DeleteShare

func (sm *Manager) DeleteShare(ctx context.Context, user *userpb.User, ref *ocm.ShareReference) error

DeleteShare deletes the share pointed by ref.

func (*Manager) GetReceivedShare

func (sm *Manager) GetReceivedShare(ctx context.Context, user *userpb.User, ref *ocm.ShareReference) (*ocm.ReceivedShare, error)

GetReceivedShare returns the information for a received share the user has access.

func (*Manager) GetShare

func (sm *Manager) GetShare(ctx context.Context, user *userpb.User, ref *ocm.ShareReference) (*ocm.Share, error)

GetShare gets the information for a share by the given ref.

func (*Manager) ListReceivedShares

func (sm *Manager) ListReceivedShares(ctx context.Context, user *userpb.User) ([]*ocm.ReceivedShare, error)

ListReceivedShares returns the list of shares the user has access.

func (*Manager) ListShares

func (sm *Manager) ListShares(ctx context.Context, user *userpb.User, filters []*ocm.ListOCMSharesRequest_Filter) ([]*ocm.Share, error)

ListShares returns the shares created by the user. If md is provided is not nil, it returns only shares attached to the given resource.

func (*Manager) SetHTTPClient

func (sm *Manager) SetHTTPClient(c *http.Client)

SetHTTPClient sets the HTTP client.

func (*Manager) StoreReceivedShare

func (sm *Manager) StoreReceivedShare(ctx context.Context, share *ocm.ReceivedShare) (*ocm.ReceivedShare, error)

StoreReceivedShare stores a received share.

func (*Manager) StoreShare

func (sm *Manager) StoreShare(ctx context.Context, share *ocm.Share) (*ocm.Share, error)

StoreShare stores a share.

func (*Manager) UpdateReceivedShare

func (sm *Manager) UpdateReceivedShare(ctx context.Context, user *userpb.User, share *ocm.ReceivedShare, fieldMask *field_mask.FieldMask) (*ocm.ReceivedShare, error)

UpdateReceivedShare updates the received share with share state.

func (*Manager) UpdateShare

func (sm *Manager) UpdateShare(ctx context.Context, user *userpb.User, ref *ocm.ShareReference, f ...*ocm.UpdateOCMShareRequest_UpdateField) (*ocm.Share, error)

UpdateShare updates the mode of the given share.

type ReceivedEfssShare added in v1.28.0

type ReceivedEfssShare struct {
	Share *EfssShare     `json:"share" validate:"required"`
	State ocm.ShareState `json:"state" validate:"required"`
}

ReceivedEfssShare is a representation of a received federated share as exchanged with the EFSS.

type Response

type Response struct {
	// contains filtered or unexported fields
}

Response contains data for the Nextcloud mock server to respond and to switch to a new server state.

type ShareManagerConfig

type ShareManagerConfig struct {
	EndPoint     string `` /* 165-byte string literal not displayed */
	SharedSecret string `mapstructure:"shared_secret"`
	WebDAVHost   string `mapstructure:"webdav_host"`
	MockHTTP     bool   `mapstructure:"mock_http"`
	MountID      string `` /* 165-byte string literal not displayed */
}

ShareManagerConfig contains config for a Nextcloud-based ShareManager.

Jump to

Keyboard shortcuts

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