Merge branch 'master' into try-gookikt-config

This commit is contained in:
A.Unger
2021-11-19 16:27:49 +01:00
12 changed files with 274 additions and 27 deletions

View File

@@ -16,7 +16,7 @@ The following sections list the changes for unreleased.
* Change - Make all insecure options configurable and change the default to false: [#2700](https://github.com/owncloud/ocis/issues/2700)
* Change - Update ownCloud Web to v4.5.0: [#2780](https://github.com/owncloud/ocis/pull/2780)
* Enhancement - Add API to list all spaces: [#2692](https://github.com/owncloud/ocis/pull/2692)
* Enhancement - Update reva to v1.16: [#2737](https://github.com/owncloud/ocis/pull/2737)
* Enhancement - Update REVA to v1.16.0: [#2737](https://github.com/owncloud/ocis/pull/2737)
## Details
@@ -112,13 +112,81 @@ The following sections list the changes for unreleased.
https://github.com/owncloud/ocis/pull/2692
* Enhancement - Update reva to v1.16: [#2737](https://github.com/owncloud/ocis/pull/2737)
* Enhancement - Update REVA to v1.16.0: [#2737](https://github.com/owncloud/ocis/pull/2737)
Updated reva to v1.16 This update includes: * TODO before oCIS release
Updated REVA to v1.16.0 This update includes: * Fix
[cs3org/reva#2245](https://github.com/cs3org/reva/pull/2245): Don't announce
search-files capability * Fix
[cs3org/reva#2247](https://github.com/cs3org/reva/pull/2247): Merge user ACLs from
EOS to sys ACLs * Fix [cs3org/reva#2279](https://github.com/cs3org/reva/pull/2279):
Return the inode of the version folder for files when listing in EOS * Fix
[cs3org/reva#2294](https://github.com/cs3org/reva/pull/2294): Fix HTTP return code
when path is invalid * Fix
[cs3org/reva#2231](https://github.com/cs3org/reva/pull/2231): Fix share permission
on a single file in sql share driver (cbox pkg) * Fix
[cs3org/reva#2230](https://github.com/cs3org/reva/pull/2230): Fix open by default app
and expose default app * Fix
[cs3org/reva#2265](https://github.com/cs3org/reva/pull/2265): Fix nil pointer
exception when resolving members of a group (rest driver) * Fix
[cs3org/reva#1214](https://github.com/cs3org/reva/pull/1214): Fix restoring
versions * Fix [cs3org/reva#2254](https://github.com/cs3org/reva/pull/2254): Fix
spaces propfind * Fix [cs3org/reva#2260](https://github.com/cs3org/reva/pull/2260):
Fix unset quota xattr on darwin * Fix
[cs3org/reva#5776](https://github.com/cs3org/reva/pull/5776): Enforce permissions
in public share apps * Fix
[cs3org/reva#2767](https://github.com/cs3org/reva/pull/2767): Fix status code for
WebDAV mkcol requests where an ancestor is missing * Fix
[cs3org/reva#2287](https://github.com/cs3org/reva/pull/2287): Add public link access
via mount-ID:token/relative-path to the scope * Fix
[cs3org/reva#2244](https://github.com/cs3org/reva/pull/2244): Fix the permissions
response for shared files in the cbox sql driver * Enh
[cs3org/reva#2219](https://github.com/cs3org/reva/pull/2219): Add virtual view tests
* Enh [cs3org/reva#2230](https://github.com/cs3org/reva/pull/2230): Add priority to
app providers * Enh [cs3org/reva#2258](https://github.com/cs3org/reva/pull/2258):
Improved error messages from the AppProviders * Enh
[cs3org/reva#2119](https://github.com/cs3org/reva/pull/2119): Add authprovider
owncloudsql * Enh [cs3org/reva#2211](https://github.com/cs3org/reva/pull/2211):
Enhance the cbox share sql driver to store accepted group shares * Enh
[cs3org/reva#2212](https://github.com/cs3org/reva/pull/2212): Filter root path
according to the agent that makes the request * Enh
[cs3org/reva#2237](https://github.com/cs3org/reva/pull/2237): Skip get user call in
eosfs in case previous ones also failed * Enh
[cs3org/reva#2266](https://github.com/cs3org/reva/pull/2266): Callback for the EOS
UID cache to retry fetch for failed keys * Enh
[cs3org/reva#2215](https://github.com/cs3org/reva/pull/2215): Aggregrate resource
info properties for virtual views * Enh
[cs3org/reva#2271](https://github.com/cs3org/reva/pull/2271): Revamp the favorite
manager and add the cbox sql driver * Enh
[cs3org/reva#2248](https://github.com/cs3org/reva/pull/2248): Cache whether a user
home was created or not * Enh
[cs3org/reva#2282](https://github.com/cs3org/reva/pull/2282): Return a proper
NOT_FOUND error when a user or group is not found * Enh
[cs3org/reva#2268](https://github.com/cs3org/reva/pull/2268): Add the reverseproxy
http service * Enh [cs3org/reva#2207](https://github.com/cs3org/reva/pull/2207):
Enable users to list all spaces * Enh
[cs3org/reva#2286](https://github.com/cs3org/reva/pull/2286): Add trace ID to
middleware loggers * Enh
[cs3org/reva#2251](https://github.com/cs3org/reva/pull/2251): Mentix service
inference * Enh [cs3org/reva#2218](https://github.com/cs3org/reva/pull/2218): Allow
filtering of mime types supported by app providers * Enh
[cs3org/reva#2213](https://github.com/cs3org/reva/pull/2213): Add public link share
type to propfind response * Enh
[cs3org/reva#2253](https://github.com/cs3org/reva/pull/2253): Support the file
editor role for public links * Enh
[cs3org/reva#2208](https://github.com/cs3org/reva/pull/2208): Reduce redundant stat
calls when statting by resource ID * Enh
[cs3org/reva#2235](https://github.com/cs3org/reva/pull/2235): Specify a list of
allowed folders/files to be archived * Enh
[cs3org/reva#2267](https://github.com/cs3org/reva/pull/2267): Restrict the paths
where share creation is allowed * Enh
[cs3org/reva#2252](https://github.com/cs3org/reva/pull/2252): Add the xattr sys.acl
to SysACL (eosgrpc) * Enh
[cs3org/reva#2239](https://github.com/cs3org/reva/pull/2239): Update toml configs
https://github.com/owncloud/ocis/pull/2737
https://github.com/owncloud/ocis/pull/2726
https://github.com/owncloud/ocis/pull/2790
https://github.com/owncloud/ocis/pull/2797
# Changelog for [1.14.0] (2021-10-27)
The following sections list the changes for 1.14.0.

View File

@@ -276,7 +276,7 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest
}
func (s Service) findAccountsByQuery(ctx context.Context, query string) ([]string, error) {
return s.index.Query(&proto.Account{}, query)
return s.index.Query(ctx, &proto.Account{}, query)
}
// GetAccount implements the AccountsServiceHandler interface

View File

@@ -88,7 +88,7 @@ func (s Service) ListGroups(ctx context.Context, in *proto.ListGroupsRequest, ou
return
}
func (s Service) findGroupsByQuery(ctx context.Context, query string) ([]string, error) {
return s.index.Query(&proto.Group{}, query)
return s.index.Query(ctx, &proto.Group{}, query)
}
// GetGroup implements the GroupsServiceHandler interface

View File

@@ -1,9 +1,48 @@
Enhancement: Update reva to v1.16
Enhancement: Update REVA to v1.16.0
Updated reva to v1.16
Updated REVA to v1.16.0
This update includes:
* TODO before oCIS release
* Fix [cs3org/reva#2245](https://github.com/cs3org/reva/pull/2245): Don't announce search-files capability
* Fix [cs3org/reva#2247](https://github.com/cs3org/reva/pull/2247): Merge user ACLs from EOS to sys ACLs
* Fix [cs3org/reva#2279](https://github.com/cs3org/reva/pull/2279): Return the inode of the version folder for files when listing in EOS
* Fix [cs3org/reva#2294](https://github.com/cs3org/reva/pull/2294): Fix HTTP return code when path is invalid
* Fix [cs3org/reva#2231](https://github.com/cs3org/reva/pull/2231): Fix share permission on a single file in sql share driver (cbox pkg)
* Fix [cs3org/reva#2230](https://github.com/cs3org/reva/pull/2230): Fix open by default app and expose default app
* Fix [cs3org/reva#2265](https://github.com/cs3org/reva/pull/2265): Fix nil pointer exception when resolving members of a group (rest driver)
* Fix [cs3org/reva#1214](https://github.com/cs3org/reva/pull/1214): Fix restoring versions
* Fix [cs3org/reva#2254](https://github.com/cs3org/reva/pull/2254): Fix spaces propfind
* Fix [cs3org/reva#2260](https://github.com/cs3org/reva/pull/2260): Fix unset quota xattr on darwin
* Fix [cs3org/reva#5776](https://github.com/cs3org/reva/pull/5776): Enforce permissions in public share apps
* Fix [cs3org/reva#2767](https://github.com/cs3org/reva/pull/2767): Fix status code for WebDAV mkcol requests where an ancestor is missing
* Fix [cs3org/reva#2287](https://github.com/cs3org/reva/pull/2287): Add public link access via mount-ID:token/relative-path to the scope
* Fix [cs3org/reva#2244](https://github.com/cs3org/reva/pull/2244): Fix the permissions response for shared files in the cbox sql driver
* Enh [cs3org/reva#2219](https://github.com/cs3org/reva/pull/2219): Add virtual view tests
* Enh [cs3org/reva#2230](https://github.com/cs3org/reva/pull/2230): Add priority to app providers
* Enh [cs3org/reva#2258](https://github.com/cs3org/reva/pull/2258): Improved error messages from the AppProviders
* Enh [cs3org/reva#2119](https://github.com/cs3org/reva/pull/2119): Add authprovider owncloudsql
* Enh [cs3org/reva#2211](https://github.com/cs3org/reva/pull/2211): Enhance the cbox share sql driver to store accepted group shares
* Enh [cs3org/reva#2212](https://github.com/cs3org/reva/pull/2212): Filter root path according to the agent that makes the request
* Enh [cs3org/reva#2237](https://github.com/cs3org/reva/pull/2237): Skip get user call in eosfs in case previous ones also failed
* Enh [cs3org/reva#2266](https://github.com/cs3org/reva/pull/2266): Callback for the EOS UID cache to retry fetch for failed keys
* Enh [cs3org/reva#2215](https://github.com/cs3org/reva/pull/2215): Aggregrate resource info properties for virtual views
* Enh [cs3org/reva#2271](https://github.com/cs3org/reva/pull/2271): Revamp the favorite manager and add the cbox sql driver
* Enh [cs3org/reva#2248](https://github.com/cs3org/reva/pull/2248): Cache whether a user home was created or not
* Enh [cs3org/reva#2282](https://github.com/cs3org/reva/pull/2282): Return a proper NOT_FOUND error when a user or group is not found
* Enh [cs3org/reva#2268](https://github.com/cs3org/reva/pull/2268): Add the reverseproxy http service
* Enh [cs3org/reva#2207](https://github.com/cs3org/reva/pull/2207): Enable users to list all spaces
* Enh [cs3org/reva#2286](https://github.com/cs3org/reva/pull/2286): Add trace ID to middleware loggers
* Enh [cs3org/reva#2251](https://github.com/cs3org/reva/pull/2251): Mentix service inference
* Enh [cs3org/reva#2218](https://github.com/cs3org/reva/pull/2218): Allow filtering of mime types supported by app providers
* Enh [cs3org/reva#2213](https://github.com/cs3org/reva/pull/2213): Add public link share type to propfind response
* Enh [cs3org/reva#2253](https://github.com/cs3org/reva/pull/2253): Support the file editor role for public links
* Enh [cs3org/reva#2208](https://github.com/cs3org/reva/pull/2208): Reduce redundant stat calls when statting by resource ID
* Enh [cs3org/reva#2235](https://github.com/cs3org/reva/pull/2235): Specify a list of allowed folders/files to be archived
* Enh [cs3org/reva#2267](https://github.com/cs3org/reva/pull/2267): Restrict the paths where share creation is allowed
* Enh [cs3org/reva#2252](https://github.com/cs3org/reva/pull/2252): Add the xattr sys.acl to SysACL (eosgrpc)
* Enh [cs3org/reva#2239](https://github.com/cs3org/reva/pull/2239): Update toml configs
https://github.com/owncloud/ocis/pull/2737
https://github.com/owncloud/ocis/pull/2726
https://github.com/owncloud/ocis/pull/2790
https://github.com/owncloud/ocis/pull/2797

View File

@@ -0,0 +1,25 @@
---
title: Rclone
date: 2021-11-17T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/clients/rclone
geekdocFilePath: _index.md
geekdocCollapseSection: true
---
## About Rclone
{{< hint ok >}}
Rclone is a command line program to manage files on cloud storage. It is a feature rich alternative to cloud vendors' web storage interfaces. Over 40 cloud storage products support rclone including S3 object stores, business & consumer file storage services, as well as standard transfer protocols.
Rclone has powerful cloud equivalents to the unix commands rsync, cp, mv, mount, ls, ncdu, tree, rm, and cat. Rclone's familiar syntax includes shell pipeline support, and --dry-run protection. It is used at the command line, in scripts or via its API.
Users call rclone "The Swiss army knife of cloud storage", and "Technology indistinguishable from magic".
{{< /hint >}}
Source: [Rclone project website](https://rclone.org/)
## Table of Contents
{{< toc-tree >}}

View File

@@ -0,0 +1,46 @@
---
title: WebDAV with Basic Authentication
date: 2021-11-17T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/clients/rclone
geekdocFilePath: webdav-sync-basic-auth.md
geekdocCollapseSection: true
---
## WebDAV with Basic Authentication
{{< hint danger >}}
Basic Authentication is disabled by default in oCIS because of security considerations. In order to make the following Rclone commands work the oCIS administrator needs to enable Basic Authentication eg. by setting the the environment variable `PROXY_ENABLE_BASIC_AUTH` to `true`.
Please consider to use [Rclone with OpenID Connect]({{< ref "webdav-sync-oidc.md" >}}) instead.
{{< /hint >}}
For the usage of a WebDAV remote with Rclone see also the [Rclone documentation](https://rclone.org/webdav/)
## Configure the WebDAV remote
First of all we need to set up our credentials and the WebDAV remote for Rclone. In this example we do this by setting environment variables. You might also set up a named remote or use command line options to achieve the same.
``` bash
export RCLONE_WEBDAV_VENDOR=owncloud
export RCLONE_WEBDAV_URL=https://ocis.owncloud.test/remote.php/webdav/
export RCLONE_WEBDAV_USER=einstein
export RCLONE_WEBDAV_PASS=$(rclone obscure relativity)
```
{{< hint info >}}
Please note that `RCLONE_WEBDAV_PASS` is not set to the actual password, but to the value returned by `rclone obscure <password>`.
{{< /hint >}}
We now can use Rclone to sync the local folder `/tmp/test` to `/test` in your oCIS home folder.
### Sync to the WebDAV remote
``` bash
rclone sync :local:/tmp :webdav:/test
```
If your oCIS doesn't use valid SSL certificates, you may need to use `rclone --no-check-certificate sync ...`.

View File

@@ -0,0 +1,66 @@
---
title: WebDAV with OpenID Connect
date: 2021-11-17T00:00:00+00:00
weight: 20
geekdocRepo: https://github.com/owncloud/ocis
geekdocEditPath: edit/master/docs/clients/rclone
geekdocFilePath: webdav-sync-oidc.md
geekdocCollapseSection: true
---
## WebDAV with OpenID Connect
Rclone itself is not able to open and maintain an OpenID Connect session. But it is able to still use OpenID Connect for authentication by leveraging a so called OIDC-agent.
### Setting up the OIDC-agent
You need to install the [OIDC-agent](https://github.com/indigo-dc/oidc-agent) from your OS' package repository (eg. [Debian](https://github.com/indigo-dc/oidc-agent#debian-packages) or [MacOS](https://github.com/indigo-dc/oidc-agent#debian-packages)).
### Configuring the the OIDC-agent
Run the following command to add a OpenID Connect profile to your OIDC-agent. It will open the login page of OpenID Connect identity provider where you need to log in if you don't have an active session.
``` bash
oidc-gen \
--client-id=oidc-agent \
--client-secret="" \
--pub \
--issuer https://ocis.owncloud.test \
--redirect-uri=http://localhost:12345 \
--scope max \
einstein-ocis-owncloud-test
```
If you have dynamic client registration enabled on your OpenID Connect identity provider, you can skip the `--client-id`, `--client-secret` and `--pub` options.
If your're using a dedicated OpenID Connect client for the OIDC-agent, we recommend a public one with the following two redirect URIs: `http://127.0.0.1:*` and `http://localhost:*`. Alternatively you also may use the already existing OIDC client of the ownCloud Desktop Client (`--client-id=xdXOt13JKxym1B1QcEncf2XDkLAexMBFwiT9j6EfhhHFJhs2KM9jbjTmf8JBXE69` and `--client-secret=UBntmLjC2yYCeHwsyj73Uwo9TAaecAetRwMw0xYcvNL9yRdLSUi0hUAHfvCHFeFh`, no `--pub` set)
Please also note that the OIDC-agent will listen on your localhost interface on port 12345 for the time of the intial authentication. If that port is already occupied on your machine, you can easily change that by setting the `--redirect-uri` parameter to a different value.
After a successful login or an already existing session you will be redirected to success page of the OIDC-agent.
You will now be asked for a password for your account configuration, so that your OIDC session is secured and cannot be used by other people with access to your computer.
## Configure the WebDAV remote
First of all we need to set up our credentials and the WebDAV remote for Rclone. In this example we do this by setting environment variables. You might also set up a named remote or use command line options to achieve the same.
``` bash
export RCLONE_WEBDAV_VENDOR=owncloud
export RCLONE_WEBDAV_URL=https://ocis.owncloud.test/remote.php/webdav/
export RCLONE_WEBDAV_BEARER_TOKEN_COMMAND="oidc-token einstein-ocis-owncloud-test"
```
### Sync to the WebDAV remote
We now can use Rclone to sync the local folder `/tmp/test` to `/test` in your oCIS home folder.
``` bash
rclone sync :local:/tmp :webdav:/test
```
If your oCIS doesn't use valid SSL certificates, you may need to use `rclone --no-check-certificate sync ...`.

6
go.mod
View File

@@ -3,7 +3,7 @@ module github.com/owncloud/ocis
go 1.17
require (
github.com/CiscoM31/godata v1.0.4
github.com/CiscoM31/godata v1.0.5
github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e
github.com/asim/go-micro/plugins/client/grpc/v4 v4.0.0-20211028090348-ed690ed838cc
github.com/asim/go-micro/plugins/logger/zerolog/v4 v4.0.0-20211028090348-ed690ed838cc
@@ -19,10 +19,10 @@ require (
github.com/blevesearch/bleve/v2 v2.2.2
github.com/coreos/go-oidc/v3 v3.1.0
github.com/cs3org/go-cs3apis v0.0.0-20211104090126-8e972dca8304
github.com/cs3org/reva v1.15.1-0.20211119095816-7cfc6d3cc8c2
github.com/cs3org/reva v1.16.0
github.com/disintegration/imaging v1.6.2
github.com/glauth/glauth/v2 v2.0.0-20211021011345-ef3151c28733
github.com/go-chi/chi/v5 v5.0.6
github.com/go-chi/chi/v5 v5.0.7
github.com/go-chi/cors v1.2.0
github.com/go-chi/render v1.0.1
github.com/go-logr/logr v0.4.0

12
go.sum
View File

@@ -71,8 +71,8 @@ github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c/go.mod h1:chxPXzS
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CiscoM31/godata v1.0.4 h1:PFGyWG3lunFVnYodKaTPxgTfenDxeCci4Td1F13fOQc=
github.com/CiscoM31/godata v1.0.4/go.mod h1:Mgl+jHnqFqMT3pPD0pcahMMqI392Z8qInjrwvsbJAb4=
github.com/CiscoM31/godata v1.0.5 h1:AITXpa/5ybXEq59A0nqUGiS7ZXVJnQtFw5o09tyN/UA=
github.com/CiscoM31/godata v1.0.5/go.mod h1:wcmFm66GMdOE316TgwFO1wo5ainCvTK26omd93oZf2M=
github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e h1:Bqtt5C+uVk+vH/t5dmB47uDCTwxw16EYHqvJnmY2aQc=
github.com/GeertJohan/yubigo v0.0.0-20190917122436-175bc097e60e/go.mod h1:njRCDrl+1RQ/A/+KVU8Ho2EWAxUSkohOWczdW3dzDG0=
github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo=
@@ -298,8 +298,8 @@ github.com/crewjam/saml v0.4.5/go.mod h1:qCJQpUtZte9R1ZjUBcW8qtCNlinbO363ooNl02S
github.com/cs3org/cato v0.0.0-20200828125504-e418fc54dd5e/go.mod h1:XJEZ3/EQuI3BXTp/6DUzFr850vlxq11I6satRtz0YQ4=
github.com/cs3org/go-cs3apis v0.0.0-20211104090126-8e972dca8304 h1:e/nIPR518vyvrulo9goAZTtYD6gFfu/2/9MDe6mTGcw=
github.com/cs3org/go-cs3apis v0.0.0-20211104090126-8e972dca8304/go.mod h1:UXha4TguuB52H14EMoSsCqDj7k8a/t7g4gVP+bgY5LY=
github.com/cs3org/reva v1.15.1-0.20211119095816-7cfc6d3cc8c2 h1:QjnDztqGCLdYtiw6enAgrWZwc7UaZj7iJeT0L4oyHpk=
github.com/cs3org/reva v1.15.1-0.20211119095816-7cfc6d3cc8c2/go.mod h1:9jmSVOnYv69pYbXfjcboTQaZPwHZ6NSD+2jjE9xx12U=
github.com/cs3org/reva v1.16.0 h1:aDMlMiCF0klEENBNDkZm+GbmnGkw/CIZGZCmv1DOgQM=
github.com/cs3org/reva v1.16.0/go.mod h1:9jmSVOnYv69pYbXfjcboTQaZPwHZ6NSD+2jjE9xx12U=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8 h1:Z9lwXumT5ACSmJ7WGnFl+OMLLjpz5uR2fyz7dC255FI=
github.com/cubewise-code/go-mime v0.0.0-20200519001935-8c5762b177d8/go.mod h1:4abs/jPXcmJzYoYGF91JF9Uq9s/KL5n1jvFDix8KcqY=
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
@@ -381,8 +381,8 @@ github.com/go-asn1-ber/asn1-ber v1.5.3/go.mod h1:hEBeB/ic+5LoWskz+yKT7vGhhPYkPro
github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAUcHlgXVRs=
github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ=
github.com/go-chi/chi/v5 v5.0.5/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.0.6 h1:CHIMAkr36TRf/zYvOqNKklMDxEm9HuqdiK+syK+tYtw=
github.com/go-chi/chi/v5 v5.0.6/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/cors v1.2.0 h1:tV1g1XENQ8ku4Bq3K9ub2AtgG+p16SmzeMSGTwrOKdE=
github.com/go-chi/cors v1.2.0/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8=

View File

@@ -257,7 +257,7 @@ func (g Graph) UpdateDrive(w http.ResponseWriter, r *http.Request) {
//https://github.com/CiscoM31/godata/blob/d70e191d2908191623be84401fecc40d6af4afde/url_parser_test.go#L10
sanitized := strings.TrimPrefix(r.URL.Path, "/graph/v1.0/")
req, err := godata.ParseRequest(sanitized, r.URL.Query(), true)
req, err := godata.ParseRequest(r.Context(), sanitized, r.URL.Query())
if err != nil {
errorcode.GeneralException.Render(w, r, http.StatusBadRequest, err.Error())
return

View File

@@ -2,6 +2,7 @@
package indexer
import (
"context"
"fmt"
"path"
"strings"
@@ -255,8 +256,8 @@ func (i *Indexer) Update(from, to interface{}) error {
}
// Query parses an OData query into something our indexer.Index understands and resolves it.
func (i *Indexer) Query(t interface{}, q string) ([]string, error) {
query, err := godata.ParseFilterString(q)
func (i *Indexer) Query(ctx context.Context, t interface{}, q string) ([]string, error) {
query, err := godata.ParseFilterString(ctx, q)
if err != nil {
return nil, err
}
@@ -353,7 +354,7 @@ func sanitizeInput(operands []string) (*indexerTuple, error) {
// is to transform godata operators and functions into supported operations on our index. At the time of this writing
// we only support `FindBy` and `FindByPartial` queries as these are the only implemented filters on indexer.Index(es).
func buildTreeFromOdataQuery(root *godata.ParseNode, tree *queryTree) error {
if root.Token.Type == godata.FilterTokenFunc { // i.e "startswith", "contains"
if root.Token.Type == godata.ExpressionTokenFunc { // i.e "startswith", "contains"
switch root.Token.Value {
case "startswith":
token := token{
@@ -372,7 +373,7 @@ func buildTreeFromOdataQuery(root *godata.ParseNode, tree *queryTree) error {
}
}
if root.Token.Type == godata.FilterTokenLogical {
if root.Token.Type == godata.ExpressionTokenLogical {
switch root.Token.Value {
case "or":
tree.insert(&token{operator: root.Token.Value})

View File

@@ -1,6 +1,7 @@
package indexer
import (
"context"
"os"
"path"
"testing"
@@ -255,6 +256,7 @@ func TestQueryDiskImpl(t *testing.T) {
dataDir, err := WriteIndexTestData(Data, "ID", "")
assert.NoError(t, err)
indexer := createDiskIndexer(dataDir)
ctx := context.Background()
err = indexer.AddIndex(&Account{}, "OnPremisesSamAccountName", "ID", "accounts", "non_unique", nil, false)
assert.NoError(t, err)
@@ -274,23 +276,23 @@ func TestQueryDiskImpl(t *testing.T) {
_, err = indexer.Add(acc)
assert.NoError(t, err)
r, err := indexer.Query(&Account{}, "on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets.
r, err := indexer.Query(ctx, &Account{}, "on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets.
assert.NoError(t, err)
assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r)
r, err = indexer.Query(&Account{}, "mail eq 'spooky@skeletons.org'") // this query will match both pets.
r, err = indexer.Query(ctx, &Account{}, "mail eq 'spooky@skeletons.org'") // this query will match both pets.
assert.NoError(t, err)
assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r)
r, err = indexer.Query(&Account{}, "on_premises_sam_account_name eq 'MrDootDoot' or mail eq 'spooky@skeletons.org'") // this query will match both pets.
r, err = indexer.Query(ctx, &Account{}, "on_premises_sam_account_name eq 'MrDootDoot' or mail eq 'spooky@skeletons.org'") // this query will match both pets.
assert.NoError(t, err)
assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r)
r, err = indexer.Query(&Account{}, "startswith(on_premises_sam_account_name,'MrDoo')") // this query will match both pets.
r, err = indexer.Query(ctx, &Account{}, "startswith(on_premises_sam_account_name,'MrDoo')") // this query will match both pets.
assert.NoError(t, err)
assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r)
r, err = indexer.Query(&Account{}, "id eq 'ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2' or on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets.
r, err = indexer.Query(ctx, &Account{}, "id eq 'ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2' or on_premises_sam_account_name eq 'MrDootDoot'") // this query will match both pets.
assert.NoError(t, err)
assert.Equal(t, []string{"ba5b6e54-e29d-4b2b-8cc4-0a0b958140d2"}, r)