Documentation ¶
Index ¶
- Variables
- func AppendPlainToOpaque(o *types.Opaque, key, value string) *types.Opaque
- func ExistsInOpaque(o *types.Opaque, key string) bool
- func ExtractGranteeID(grantee *provider.Grantee) (*userpb.UserId, *grouppb.GroupId)
- func FormatStorageSpaceReference(ref *provider.Reference) (string, error)
- func GetClientIP(r *http.Request) (string, error)
- func GetLDAPConnection(c *LDAPConn) (*ldap.Conn, 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 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 MakeRelativePath(p string) string
- func MarshalProtoV1ToJSON(m proto.Message) ([]byte, error)
- func ParseStorageSpaceReference(sRef string) (provider.Reference, error)
- func RandString(n int) string
- func ReadPlainFromOpaque(o *types.Opaque, key string) string
- 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 SplitStorageSpaceID(ssid string) (storageid, nodeid string, err error)
- func TSNow() *types.Timestamp
- func TSToTime(ts *types.Timestamp) time.Time
- func TSToUnixNano(ts *types.Timestamp) uint64
- func ToSnakeCase(str string) string
- func UnmarshalJSONToProtoV1(b []byte, m proto.Message) error
- func UserEqual(u, v *userpb.UserId) bool
- func UserTypeMap(accountType string) userpb.UserType
- func UserTypeToString(accountType userpb.UserType) string
- type LDAPConn
Constants ¶
This section is empty.
Variables ¶
var ( // GlobalRegistry configures a service registry globally accessible. It defaults to a memory registry. The usage of // globals is not encouraged, and this is a workaround until the PR is out of a draft state. GlobalRegistry registry.Registry = memory.New(map[string]interface{}{}) ShareStorageProviderID = "a0ca6a90-a365-4782-871e-d44447bbc668" // PublicStorageProviderID is the id used by the sharestorageprovider PublicStorageProviderID = "7993447f-687f-490d-875c-ac95e89a62a4" // SpaceGrant is used to signal the storageprovider that the grant is on a space SpaceGrant struct{} )
Functions ¶
func AppendPlainToOpaque ¶
AppendPlainToOpaque adds a new key value pair as a plain string on the given opaque and returns it
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 FormatStorageSpaceReference ¶ added in v2.1.0
FormatStorageSpaceReference will format a storage space reference into a string representation. If ref or ref.ResourceId are nil an error will be returned. The function doesn't check if all values are set. The resulting format can be:
"storage_id!opaque_id" "storage_id!opaque_id/path" "storage_id/path" "storage_id"
func GetClientIP ¶
GetClientIP retrieves the client IP from incoming requests
func GetLDAPConnection ¶
GetLDAPConnection initializes an LDAPS connection and allows to set TLS options e.g. to add trusted Certificates or disable Certificate verification
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 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 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 ParseStorageSpaceReference ¶
ParseStorageSpaceReference parses a string into a spaces reference. The expected format is `<storageid>!<nodeid>/<path>`.
func ReadPlainFromOpaque ¶
ReadPlainFromOpaque reads a plain string from the given opaque map
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 SplitStorageSpaceID ¶
SplitStorageSpaceID can be used to split `storagespaceid` into `storageid` and `nodeid`. If no specific node is appended with a `!` separator the spaceid is used as nodeid, identifying the root of the space.
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 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 { Hostname string `mapstructure:"hostname"` Port int `mapstructure:"port"` Insecure bool `mapstructure:"insecure"` CACert string `mapstructure:"cacert"` BindUsername string `mapstructure:"bind_username"` BindPassword string `mapstructure:"bind_password"` }
LDAPConn holds the basic parameter for setting up an LDAP connection.