Documentation ¶
Index ¶
- Variables
- func AppendJSONToOpaque(o *types.Opaque, key string, value interface{}) *types.Opaque
- func AppendPlainToOpaque(o *types.Opaque, key, value string) *types.Opaque
- func CheckPermission(ctx context.Context, perm string, gwc gateway.GatewayAPIClient) (bool, error)
- func ExistsInOpaque(o *types.Opaque, key string) bool
- func ExtractGranteeID(grantee *provider.Grantee) (*userpb.UserId, *grouppb.GroupId)
- func GetAcceptedUserWithContext(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error)
- func GetAppViewMode(viewMode string) appprovider.ViewMode
- func GetClientIP(r *http.Request) (string, error)
- func GetGroupMembers(ctx context.Context, groupID string, gwc gateway.GatewayAPIClient) ([]string, error)
- func GetLDAPClientForAuth(c *LDAPConn) (ldap.Client, error)
- func GetLDAPClientWithReconnect(c *LDAPConn) (ldap.Client, error)
- func GetResource(ctx context.Context, ref *storageprovider.Reference, ...) (*storageprovider.ResourceInfo, error)
- func GetResourceByID(ctx context.Context, resourceid *storageprovider.ResourceId, ...) (*storageprovider.ResourceInfo, error)
- func GetServiceUserContext(serviceUserID string, gwc gateway.GatewayAPIClient, serviceUserSecret string) (context.Context, error)
- func GetServiceUserContextWithContext(ctx context.Context, gwc gateway.GatewayAPIClient, serviceUserID string, ...) (context.Context, error)
- func GetServiceUserToken(ctx context.Context, gwc gateway.GatewayAPIClient, serviceUserID string, ...) (string, error)
- func GetSpace(ctx context.Context, spaceID string, gwc gateway.GatewayAPIClient) (*storageprovider.StorageSpace, error)
- func GetSpaceMembers(ctx context.Context, spaceID string, gwc gateway.GatewayAPIClient, ...) ([]string, error)
- func GetUser(userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error)
- func GetUserWithContext(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error)
- func GetViewMode(viewMode string) gateway.OpenInAppRequest_ViewMode
- func GranteeEqual(u, v *provider.Grantee) bool
- func GroupEqual(u, v *grouppb.GroupId) bool
- func IsAbsolutePathReference(ref *provider.Reference) bool
- func IsAbsoluteReference(ref *provider.Reference) bool
- func IsEmailValid(e string) bool
- func IsRelativeReference(ref *provider.Reference) bool
- func IsSpaceRoot(ri *storageprovider.ResourceInfo) bool
- func IsStatusCodeError(err error, code rpc.Code) bool
- func IsValidName(name string) bool
- func IsValidPhoneNumber(number string) bool
- func IsValidWebAddress(address string) bool
- func LaterTS(t1 *types.Timestamp, t2 *types.Timestamp) *types.Timestamp
- func MTimeToTS(v string) (ts types.Timestamp, err error)
- func MTimeToTime(v string) (t time.Time, err error)
- func MakeRelativePath(p string) string
- func MarshalProtoV1ToJSON(m proto.Message) ([]byte, error)
- func MergeOpaques(o *types.Opaque, p *types.Opaque) *types.Opaque
- func RandString(n int) string
- func ReadJSONFromOpaque(o *types.Opaque, key string, valptr interface{}) error
- func ReadPlainFromOpaque(o *types.Opaque, key string) string
- func RemoveItem(path string) error
- func ResolveID(ctx context.Context, userid *user.UserId, groupid *group.GroupId, ...) ([]string, error)
- func ResolvePath(path string) (string, error)
- func ResourceEqual(u, v *provider.Reference) bool
- func ResourceIDEqual(u, v *provider.ResourceId) bool
- func Skip(source string, prefixes []string) bool
- func StatusCodeErrorToCS3Status(err error) *rpc.Status
- func TSNow() *types.Timestamp
- func TSToTime(ts *types.Timestamp) time.Time
- func TSToUnixNano(ts *types.Timestamp) uint64
- func TimeToTS(t time.Time) *types.Timestamp
- func ToSnakeCase(str string) string
- func UnmarshalJSONToProtoV1(b []byte, m proto.Message) error
- func UserEqual(u, v *userpb.UserId) bool
- func UserIDEqual(u, v *userpb.UserId) bool
- func UserTypeMap(accountType string) userpb.UserType
- func UserTypeToString(accountType userpb.UserType) string
- type LDAPConn
- type SpaceRole
Constants ¶
This section is empty.
Variables ¶
var ( IsErrNotFound = func(err error) bool { return IsStatusCodeError(err, rpc.Code_CODE_NOT_FOUND) } IsErrPermissionDenied = func(err error) bool { return IsStatusCodeError(err, rpc.Code_CODE_PERMISSION_DENIED) } )
Package error checkers
var ( // PublicStorageProviderID is the storage id used by the sharestorageprovider PublicStorageProviderID = "7993447f-687f-490d-875c-ac95e89a62a4" // PublicStorageSpaceID is the space id used by the sharestorageprovider PublicStorageSpaceID = "7993447f-687f-490d-875c-ac95e89a62a4" // OCMStorageProviderID is the storage id used by the ocmreceived storageprovider OCMStorageProviderID = "89f37a33-858b-45fa-8890-a1f2b27d90e1" // OCMStorageSpaceID is the space id used by the ocmreceived storageprovider OCMStorageSpaceID = "89f37a33-858b-45fa-8890-a1f2b27d90e1" // SpaceGrant is used to signal the storageprovider that the grant is on a space SpaceGrant struct{} )ShareStorageProviderID = "a0ca6a90-a365-4782-871e-d44447bbc668" ShareStorageSpaceID = "a0ca6a90-a365-4782-871e-d44447bbc668"
Functions ¶
func AppendJSONToOpaque ¶ added in v2.13.0
AppendJSONToOpaque adds a new key value pair as a json on the given opaque and returns it. Ignores errors
func AppendPlainToOpaque ¶
AppendPlainToOpaque adds a new key value pair as a plain string on the given opaque and returns it
func CheckPermission ¶ added in v2.17.0
CheckPermission checks if the user role contains the given permission
func ExistsInOpaque ¶ added in v2.1.0
ExistsInOpaque returns true if the key exists in the opaque (ignoring the value)
func ExtractGranteeID ¶
ExtractGranteeID returns the ID, user or group, set in the GranteeId object
func GetAcceptedUserWithContext ¶ added in v2.20.0
func GetAcceptedUserWithContext(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error)
GetUserWithContext gets the specified accepted user
func GetAppViewMode ¶ added in v2.17.0
func GetAppViewMode(viewMode string) appprovider.ViewMode
GetAppViewMode converts a human-readable string to an appprovider view mode for opening a resource in an app.
func GetClientIP ¶
GetClientIP retrieves the client IP from incoming requests
func GetGroupMembers ¶ added in v2.17.0
func GetGroupMembers(ctx context.Context, groupID string, gwc gateway.GatewayAPIClient) ([]string, error)
GetGroupMembers returns all members of the given group
func GetLDAPClientForAuth ¶ added in v2.2.0
GetLDAPClientForAuth initializes an LDAP connection. The connection is not authenticated when returned. The main purpose for GetLDAPClientForAuth is to get and LDAP connection that can be used to issue a single bind request to authenticate a user.
func GetLDAPClientWithReconnect ¶ added in v2.2.0
GetLDAPClientWithReconnect initializes a long-lived LDAP connection that automatically reconnects on connection errors. It allows to set TLS options e.g. to add trusted Certificates or disable Certificate verification
func GetResource ¶ added in v2.17.0
func GetResource(ctx context.Context, ref *storageprovider.Reference, gwc gateway.GatewayAPIClient) (*storageprovider.ResourceInfo, error)
GetResource returns a resource by reference
func GetResourceByID ¶ added in v2.17.0
func GetResourceByID(ctx context.Context, resourceid *storageprovider.ResourceId, gwc gateway.GatewayAPIClient) (*storageprovider.ResourceInfo, error)
GetResourceByID is a convenience method to get a resource by its resourceID
func GetServiceUserContext ¶ added in v2.17.0
func GetServiceUserContext(serviceUserID string, gwc gateway.GatewayAPIClient, serviceUserSecret string) (context.Context, error)
GetServiceUserContext returns an authenticated context of the given service user Deprecated: Use GetServiceUserContextWithContext()
func GetServiceUserContextWithContext ¶ added in v2.19.2
func GetServiceUserContextWithContext(ctx context.Context, gwc gateway.GatewayAPIClient, serviceUserID string, serviceUserSecret string) (context.Context, error)
GetServiceUserContextWithContext returns an authenticated context of the given service user
func GetServiceUserToken ¶ added in v2.21.0
func GetServiceUserToken(ctx context.Context, gwc gateway.GatewayAPIClient, serviceUserID string, serviceUserSecret string) (string, error)
GetServiceUserToken returns a reva authentication token for the given service user
func GetSpace ¶ added in v2.17.0
func GetSpace(ctx context.Context, spaceID string, gwc gateway.GatewayAPIClient) (*storageprovider.StorageSpace, error)
GetSpace returns the given space
func GetSpaceMembers ¶ added in v2.17.0
func GetSpaceMembers(ctx context.Context, spaceID string, gwc gateway.GatewayAPIClient, role SpaceRole) ([]string, error)
GetSpaceMembers returns all members of the given space that have at least the given role. `nil` role will be interpreted as all
func GetUser ¶ added in v2.13.0
GetUser gets the specified user Deprecated: Use GetUserWithContext()
func GetUserWithContext ¶ added in v2.19.2
func GetUserWithContext(ctx context.Context, userID *user.UserId, gwc gateway.GatewayAPIClient) (*user.User, error)
GetUserWithContext gets the specified user
func GetViewMode ¶
func GetViewMode(viewMode string) gateway.OpenInAppRequest_ViewMode
GetViewMode converts a human-readable string to a view mode for opening a resource in an app.
func GranteeEqual ¶
GranteeEqual returns whether two grantees have the same field values.
func GroupEqual ¶
GroupEqual returns whether two groups have the same field values.
func IsAbsolutePathReference ¶
IsAbsolutePathReference returns true if the given reference qualifies as a global path when only the path is set and starts with /
func IsAbsoluteReference ¶
IsAbsoluteReference returns true if the given reference qualifies as absolute when either only the resource id is set or only the path is set and starts with /
TODO(corby): Currently if the path is empty, the ResourceId is set but has empty storageId and OpaqueId then the reference is still being viewed as absolute. We need to check if we want that because in some places we might not want to set both StorageId and OpaqueId so we can't do a hard check if they are set.
func IsEmailValid ¶
IsEmailValid checks whether the provided email has a valid format.
func IsRelativeReference ¶
IsRelativeReference returns true if the given reference qualifies as relative when the resource id is set and the path starts with a .
TODO(corby): Currently if the path begins with a dot, the ResourceId is set but has empty storageId and OpaqueId then the reference is still being viewed as relative. We need to check if we want that because in some places we might not want to set both StorageId and OpaqueId so we can't do a hard check if they are set.
func IsSpaceRoot ¶ added in v2.19.5
func IsSpaceRoot(ri *storageprovider.ResourceInfo) bool
IsSpaceRoot checks if the given resource info is referring to a space root
func IsStatusCodeError ¶ added in v2.17.0
IsStatusCodeError returns true if `err` was caused because of status code `code`
func IsValidName ¶
IsValidName cheks if the given name doesn't contain any non-alpha, space or dash characters.
func IsValidPhoneNumber ¶
IsValidPhoneNumber checks whether the provided phone number has a valid format.
func IsValidWebAddress ¶
IsValidWebAddress checks whether the provided address is a valid URL.
func MTimeToTS ¶ added in v2.8.0
MTimeToTS converts a string in the form "<unix>.<nanoseconds>" into a CS3 Timestamp
func MTimeToTime ¶ added in v2.16.0
MTimeToTime converts a string in the form "<unix>.<nanoseconds>" into a go time.Time
func MakeRelativePath ¶
MakeRelativePath prefixes the path with a . to use it in a relative reference
func MarshalProtoV1ToJSON ¶
MarshalProtoV1ToJSON marshals a proto V1 message to a JSON byte array TODO: update this once we start using V2 in CS3APIs
func MergeOpaques ¶ added in v2.6.0
MergeOpaques will merge the opaques. If a key exists in both opaques the values from the first opaque will be taken
func ReadJSONFromOpaque ¶ added in v2.13.0
ReadJSONFromOpaque reads and unmarshals a value from the opaque in the given interface{} (Make sure it's a pointer!)
func ReadPlainFromOpaque ¶
ReadPlainFromOpaque reads a plain string from the given opaque map
func RemoveItem ¶ added in v2.4.0
RemoveItem removes the given item, its children and all empty parent folders
func ResolveID ¶ added in v2.17.0
func ResolveID(ctx context.Context, userid *user.UserId, groupid *group.GroupId, gwc gateway.GatewayAPIClient) ([]string, error)
ResolveID returns either the given userID or all members of the given groupID (if userID is nil)
func ResolvePath ¶
ResolvePath converts relative local paths to absolute paths
func ResourceEqual ¶
ResourceEqual returns whether two resources have the same field values.
func ResourceIDEqual ¶
func ResourceIDEqual(u, v *provider.ResourceId) bool
ResourceIDEqual returns whether two resources have the same field values.
func Skip ¶
Skip evaluates whether a source endpoint contains any of the prefixes. i.e: /a/b/c/d/e contains prefix /a/b/c
func StatusCodeErrorToCS3Status ¶ added in v2.20.0
StatusCodeErrorToCS3Status translate the `statusCodeError` type to CS3 Status returns nil if `err` does not match to the `statusCodeError` type
func TSToUnixNano ¶
TSToUnixNano converts a protobuf Timestamp to uint64 with nanoseconds resolution.
func ToSnakeCase ¶
ToSnakeCase converts a CamelCase string to a snake_case string.
func UnmarshalJSONToProtoV1 ¶
UnmarshalJSONToProtoV1 decodes a JSON byte array to a specified proto message type TODO: update this once we start using V2 in CS3APIs
func UserIDEqual ¶ added in v2.11.0
UserIDEqual returns whether two users have the same opaqueid values. The idp is ignored
func UserTypeMap ¶
UserTypeMap translates account type string to CS3 UserType
func UserTypeToString ¶
UserTypeToString translates CS3 UserType to user-readable string
Types ¶
type LDAPConn ¶
type LDAPConn struct { URI string `mapstructure:"uri"` Insecure bool `mapstructure:"insecure"` CACert string `mapstructure:"cacert"` BindDN string `mapstructure:"bind_username"` BindPassword string `mapstructure:"bind_password"` }
LDAPConn holds the basic parameter for setting up an LDAP connection.
type SpaceRole ¶ added in v2.17.0
type SpaceRole func(*storageprovider.ResourcePermissions) bool
SpaceRole defines the user role on space
var ( AllRole SpaceRole = func(perms *storageprovider.ResourcePermissions) bool { return true } ViewerRole SpaceRole = func(perms *storageprovider.ResourcePermissions) bool { return perms.Stat } EditorRole SpaceRole = func(perms *storageprovider.ResourcePermissions) bool { return perms.InitiateFileUpload } ManagerRole SpaceRole = func(perms *storageprovider.ResourcePermissions) bool { return perms.DenyGrant } )
Possible roles in spaces