Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New metadata flags #3750

Merged
merged 5 commits into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/apps-viewmode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Apps: fixed viewMode resolution

Currently, the viewMode passed on /app/open is taken without validating
the actual user's permissions. This PR fixes this.

https://github.com/cs3org/reva/pull/3805
9 changes: 9 additions & 0 deletions changelog/unreleased/fix-unshare-eos.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Bugfix: Fix unshare for EOS storage driver

In the EOS storage driver, the remove acl operation was a no-op.
After removing a share, the recipient of the share was still able
to operate on the shared resource.
Now this has been fixed, removing correctly the ACL from the shared
resource.

https://github.com/cs3org/reva/pull/3794
5 changes: 5 additions & 0 deletions changelog/unreleased/mentix-prodflags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: New metadata flags

Several new flags, like site infrastructure and service status, are now gathered and exposed by Mentix.

https://github.com/cs3org/reva/pull/3750
14 changes: 9 additions & 5 deletions internal/http/services/appprovider/appprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,19 +449,23 @@ func filterAppsByUserAgent(mimeTypes []*appregistry.MimeTypeInfo, userAgent stri
}

func resolveViewMode(res *provider.ResourceInfo, vm string) gateway.OpenInAppRequest_ViewMode {
var viewMode gateway.OpenInAppRequest_ViewMode
if vm != "" {
return utils.GetViewMode(vm)
viewMode = utils.GetViewMode(vm)
} else {
viewMode = gateway.OpenInAppRequest_VIEW_MODE_READ_WRITE
}

var viewMode gateway.OpenInAppRequest_ViewMode
canEdit := res.PermissionSet.InitiateFileUpload
canView := res.PermissionSet.InitiateFileDownload

switch {
case canEdit && canView:
viewMode = gateway.OpenInAppRequest_VIEW_MODE_READ_WRITE
// ok
case canView:
viewMode = gateway.OpenInAppRequest_VIEW_MODE_READ_ONLY
if viewMode == gateway.OpenInAppRequest_VIEW_MODE_READ_WRITE || viewMode == gateway.OpenInAppRequest_VIEW_MODE_PREVIEW {
// downgrade to the maximum permitted viewmode
viewMode = gateway.OpenInAppRequest_VIEW_MODE_READ_ONLY
}
default:
// no permissions, will return access denied
viewMode = gateway.OpenInAppRequest_VIEW_MODE_INVALID
Expand Down
1 change: 1 addition & 0 deletions pkg/eosclient/eosbinary/eosbinary.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ func (c *Client) RemoveACL(ctx context.Context, auth, rootAuth eosclient.Authori
return err
}

a.Permissions = ""
sysACL := a.CitrineSerialize()
args := []string{"acl", "--sys"}
if finfo.IsDir {
Expand Down
52 changes: 30 additions & 22 deletions pkg/mentix/connectors/gocdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,23 @@ func (connector *GOCDBConnector) querySites(meshData *meshdata.MeshData, op *mes
organization := meshdata.GetPropertyValue(properties, meshdata.PropertyOrganization, site.OfficialName)

meshsite := &meshdata.Site{
ID: siteID,
Name: site.ShortName,
FullName: site.OfficialName,
Organization: organization,
Domain: site.Domain,
Homepage: site.Homepage,
Email: site.Email,
Description: site.Description,
Country: site.Country,
CountryCode: site.CountryCode,
Longitude: site.Longitude,
Latitude: site.Latitude,
Services: nil,
Properties: properties,
Downtimes: meshdata.Downtimes{},
ID: siteID,
Name: site.ShortName,
FullName: site.OfficialName,
Organization: organization,
Domain: site.Domain,
Infrastructure: site.Infrastructure,
Certification: site.Certification,
Homepage: site.Homepage,
Email: site.Email,
Description: site.Description,
Country: site.Country,
CountryCode: site.CountryCode,
Longitude: site.Longitude,
Latitude: site.Latitude,
Services: nil,
Properties: properties,
Downtimes: meshdata.Downtimes{},
}
op.Sites = append(op.Sites, meshsite)
}
Expand Down Expand Up @@ -230,20 +232,22 @@ func (connector *GOCDBConnector) queryServices(meshData *meshdata.MeshData, site
Name: endpoint.Name,
RawURL: endpoint.URL,
URL: getServiceURLString(service, endpoint, host),
IsMonitored: strings.EqualFold(endpoint.IsMonitored, "Y"),
IsMonitored: connector.convertStringToBool(endpoint.IsMonitored),
Properties: connector.extensionsToMap(&endpoint.Extensions),
})
}

// Add the service to the site
site.Services = append(site.Services, &meshdata.Service{
ServiceEndpoint: &meshdata.ServiceEndpoint{
Type: connector.findServiceType(meshData, service.Type),
Name: service.Type,
RawURL: service.URL,
URL: getServiceURLString(service, nil, host),
IsMonitored: strings.EqualFold(service.IsMonitored, "Y"),
Properties: connector.extensionsToMap(&service.Extensions),
Type: connector.findServiceType(meshData, service.Type),
Name: service.Type,
RawURL: service.URL,
URL: getServiceURLString(service, nil, host),
IsInProduction: connector.convertStringToBool(service.IsInProduction),
IsBeta: connector.convertStringToBool(service.IsBeta),
IsMonitored: connector.convertStringToBool(service.IsMonitored),
Properties: connector.extensionsToMap(&service.Extensions),
},
Host: host,
AdditionalEndpoints: endpoints,
Expand Down Expand Up @@ -332,6 +336,10 @@ func (connector *GOCDBConnector) getServiceURL(service *gocdb.Service, endpoint
return svcURL, nil
}

func (connector *GOCDBConnector) convertStringToBool(s string) bool {
return strings.EqualFold(s, "Y")
}

// GetID returns the ID of the connector.
func (connector *GOCDBConnector) GetID() string {
return config.ConnectorIDGOCDB
Expand Down
38 changes: 21 additions & 17 deletions pkg/mentix/connectors/gocdb/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,19 @@ type NGIs struct {

// Site represents a site in GOCDB.
type Site struct {
ShortName string `xml:"SHORT_NAME"`
OfficialName string `xml:"OFFICIAL_NAME"`
Description string `xml:"SITE_DESCRIPTION"`
Homepage string `xml:"HOME_URL"`
Email string `xml:"CONTACT_EMAIL"`
Domain string `xml:"DOMAIN>DOMAIN_NAME"`
Country string `xml:"COUNTRY"`
CountryCode string `xml:"COUNTRY_CODE"`
Latitude float32 `xml:"LATITUDE"`
Longitude float32 `xml:"LONGITUDE"`
Extensions Extensions `xml:"EXTENSIONS"`
ShortName string `xml:"SHORT_NAME"`
OfficialName string `xml:"OFFICIAL_NAME"`
Description string `xml:"SITE_DESCRIPTION"`
Homepage string `xml:"HOME_URL"`
Email string `xml:"CONTACT_EMAIL"`
Domain string `xml:"DOMAIN>DOMAIN_NAME"`
Infrastructure string `xml:"PRODUCTION_INFRASTRUCTURE"`
Certification string `xml:"CERTIFICATION_STATUS"`
Country string `xml:"COUNTRY"`
CountryCode string `xml:"COUNTRY_CODE"`
Latitude float32 `xml:"LATITUDE"`
Longitude float32 `xml:"LONGITUDE"`
Extensions Extensions `xml:"EXTENSIONS"`
}

// Sites is a list of Site objects.
Expand All @@ -89,12 +91,14 @@ type ServiceEndpoints struct {

// Service represents a service in GOCDB.
type Service struct {
Host string `xml:"HOSTNAME"`
Type string `xml:"SERVICE_TYPE"`
IsMonitored string `xml:"NODE_MONITORED"`
URL string `xml:"URL"`
Endpoints ServiceEndpoints `xml:"ENDPOINTS"`
Extensions Extensions `xml:"EXTENSIONS"`
Host string `xml:"HOSTNAME"`
Type string `xml:"SERVICE_TYPE"`
IsInProduction string `xml:"IN_PRODUCTION"`
IsBeta string `xml:"BETA"`
IsMonitored string `xml:"NODE_MONITORED"`
URL string `xml:"URL"`
Endpoints ServiceEndpoints `xml:"ENDPOINTS"`
Extensions Extensions `xml:"EXTENSIONS"`
}

// Services is a list of Service objects.
Expand Down
21 changes: 19 additions & 2 deletions pkg/mentix/exchangers/exporters/cs3api/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"fmt"
"net/http"
"net/url"
"strconv"
"strings"

ocmprovider "github.com/cs3org/go-cs3apis/cs3/ocm/provider/v1beta1"
Expand Down Expand Up @@ -95,14 +96,26 @@ func convertMeshDataToOCMData(meshData *meshdata.MeshData, elevatedServiceTypes
Services: services,
Properties: site.Properties,
}
provider.Properties[strings.ToUpper(meshdata.PropertyOperator)] = op.ID // Propagate the operator ID as a property
// Propagate the operator ID as a property
setPropertyValue(provider.Properties, meshdata.PropertyOperator, op.ID)
// Expose additional site details as properties
setPropertyValue(provider.Properties, meshdata.PropertyInfrastructure, site.Infrastructure)
setPropertyValue(provider.Properties, meshdata.PropertyCertification, site.Certification)
providers = append(providers, provider)
}
}
return providers, nil
}

func convertServiceEndpointToOCMData(endpoint *meshdata.ServiceEndpoint, log *zerolog.Logger) *ocmprovider.ServiceEndpoint {
properties := make(map[string]string, 10)
for k, v := range endpoint.Properties {
properties[k] = v
}
// Expose additional service details as properties
setPropertyValue(properties, meshdata.PropertyIsInProduction, strconv.FormatBool(endpoint.IsInProduction))
setPropertyValue(properties, meshdata.PropertyIsBeta, strconv.FormatBool(endpoint.IsBeta))

return &ocmprovider.ServiceEndpoint{
Type: &ocmprovider.ServiceType{
Name: endpoint.Type.Name,
Expand All @@ -111,6 +124,10 @@ func convertServiceEndpointToOCMData(endpoint *meshdata.ServiceEndpoint, log *ze
Name: endpoint.Name,
Path: normalizeURLPath(endpoint.URL, log),
IsMonitored: endpoint.IsMonitored,
Properties: endpoint.Properties,
Properties: properties,
}
}

func setPropertyValue(properties map[string]string, key string, value string) {
properties[strings.ToUpper(key)] = value
}
9 changes: 9 additions & 0 deletions pkg/mentix/meshdata/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ const (

// PropertyAPIVersion identifies the API version property.
PropertyAPIVersion = "api_version"

// PropertyInfrastructure identifies the infrastructure type of a site.
PropertyInfrastructure = "infrastructure"
// PropertyCertification identifies the certification status of a site.
PropertyCertification = "certification"
// PropertyIsInProduction identifies if a service is in production.
PropertyIsInProduction = "in_production"
// PropertyIsBeta identifies if a service is in beta.
PropertyIsBeta = "beta"
)

// GetPropertyValue performs a case-insensitive search for the given property.
Expand Down
14 changes: 8 additions & 6 deletions pkg/mentix/meshdata/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ func (serviceType *ServiceType) Verify() error {

// ServiceEndpoint represents a service endpoint managed by Mentix.
type ServiceEndpoint struct {
Type *ServiceType
Name string
RawURL string
URL string
IsMonitored bool
Properties map[string]string
Type *ServiceType
Name string
RawURL string
URL string
IsInProduction bool
IsBeta bool
IsMonitored bool
Properties map[string]string
}

// InferMissingData infers missing data from other data where possible.
Expand Down
28 changes: 15 additions & 13 deletions pkg/mentix/meshdata/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ import (

// Site represents a single site managed by Mentix.
type Site struct {
ID string
Name string
FullName string
Organization string
Domain string
Homepage string
Email string
Description string
Country string
CountryCode string
Location string
Latitude float32
Longitude float32
ID string
Name string
FullName string
Organization string
Domain string
Infrastructure string
Certification string
Homepage string
Email string
Description string
Country string
CountryCode string
Location string
Latitude float32
Longitude float32

Services []*Service
Properties map[string]string
Expand Down