diff --git a/go.mod b/go.mod index f9d4f7cdd..f07cb1c9c 100644 --- a/go.mod +++ b/go.mod @@ -4,22 +4,30 @@ go 1.13 require ( github.com/CiscoM31/godata v0.0.0-20191007193734-c2c4ebb1b415 + github.com/blevesearch/bleve v1.0.9 + github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d // indirect + github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 // indirect + github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 // indirect + github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect + github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect + github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect github.com/go-test/deep v1.0.6 // indirect github.com/gogo/protobuf v1.3.1 // indirect github.com/golang/protobuf v1.4.1 github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect + github.com/jmhodges/levigo v1.0.0 // indirect github.com/joho/godotenv v1.3.0 github.com/micro/cli/v2 v2.1.2 - github.com/micro/go-micro v1.18.0 github.com/micro/go-micro/v2 v2.6.0 github.com/oklog/run v1.1.0 github.com/owncloud/ocis-pkg/v2 v2.2.1 github.com/owncloud/ocis-settings v0.0.0-20200522101320-46ea31026363 + github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect github.com/restic/calens v0.2.0 github.com/rs/zerolog v1.17.2 github.com/spf13/viper v1.6.3 + github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect google.golang.org/genproto v0.0.0-20200420144010-e5e8543f8aeb - gopkg.in/ldap.v2 v2.5.1 honnef.co/go/tools v0.0.1-2020.1.0.20200427215036-cd1ad299aeab // indirect ) diff --git a/go.sum b/go.sum index 0c2e6151b..af773073e 100644 --- a/go.sum +++ b/go.sum @@ -63,6 +63,8 @@ github.com/OpenDNS/vegadns2client v0.0.0-20180418235048-a3fa4a771d87/go.mod h1:i github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w= +github.com/RoaringBitmap/roaring v0.4.21 h1:WJ/zIlNX4wQZ9x8Ey33O1UaD9TCTakYsdLFSBcTwH+8= +github.com/RoaringBitmap/roaring v0.4.21/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06Mq5mKs52e1TwOo= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/sarama v1.24.1/go.mod h1:fGP8eQ6PugKEI0iUETYYtnP6d1pH/bdDMTel1X5ajsU= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= @@ -114,6 +116,26 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/blang/semver v3.1.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= +github.com/blevesearch/bleve v1.0.9 h1:kqw/Ank/61UV9/Bx9kCcnfH6qWPgmS8O5LNfpsgzASg= +github.com/blevesearch/bleve v1.0.9/go.mod h1:tb04/rbU29clbtNgorgFd8XdJea4x3ybYaOjWKr+UBU= +github.com/blevesearch/blevex v0.0.0-20190916190636-152f0fe5c040 h1:SjYVcfJVZoCfBlg+fkaq2eoZHTf5HaJfaTeTkOtyfHQ= +github.com/blevesearch/blevex v0.0.0-20190916190636-152f0fe5c040/go.mod h1:WH+MU2F4T0VmSdaPX+Wu5GYoZBrYWdOZWSjzvYcDmqQ= +github.com/blevesearch/go-porterstemmer v1.0.3 h1:GtmsqID0aZdCSNiY8SkuPJ12pD4jI+DdXTAn4YRcHCo= +github.com/blevesearch/go-porterstemmer v1.0.3/go.mod h1:angGc5Ht+k2xhJdZi511LtmxuEf0OVpvUUNrwmM1P7M= +github.com/blevesearch/mmap-go v1.0.2 h1:JtMHb+FgQCTTYIhtMvimw15dJwu1Y5lrZDMOFXVWPk0= +github.com/blevesearch/mmap-go v1.0.2/go.mod h1:ol2qBqYaOUsGdm7aRMRrYGgPvnwLe6Y+7LMvAB5IbSA= +github.com/blevesearch/segment v0.9.0 h1:5lG7yBCx98or7gK2cHMKPukPZ/31Kag7nONpoBt22Ac= +github.com/blevesearch/segment v0.9.0/go.mod h1:9PfHYUdQCgHktBgvtUOF4x+pc4/l8rdH0u5spnW85UQ= +github.com/blevesearch/snowballstem v0.9.0 h1:lMQ189YspGP6sXvZQ4WZ+MLawfV8wOmPoD/iWeNXm8s= +github.com/blevesearch/snowballstem v0.9.0/go.mod h1:PivSj3JMc8WuaFkTSRDW2SlrulNWPl4ABg1tC/hlgLs= +github.com/blevesearch/zap/v11 v11.0.9 h1:wlSrDBeGN1G4M51NQHIXca23ttwUfQpWaK7uhO5lRSo= +github.com/blevesearch/zap/v11 v11.0.9/go.mod h1:47hzinvmY2EvvJruzsSCJpro7so8L1neseaGjrtXHOY= +github.com/blevesearch/zap/v12 v12.0.9 h1:PpatkY+BLVFZf0Ok3/fwgI/I4RU0z5blXFGuQANmqXk= +github.com/blevesearch/zap/v12 v12.0.9/go.mod h1:paQuvxy7yXor+0Mx8p2KNmJgygQbQNN+W6HRfL5Hvwc= +github.com/blevesearch/zap/v13 v13.0.1 h1:NSCM6uKu77Vn/x9nlPp4pE1o/bftqcOWZEHSyZVpGBQ= +github.com/blevesearch/zap/v13 v13.0.1/go.mod h1:XmyNLMvMf8Z5FjLANXwUeDW3e1+o77TTGUWrth7T9WI= +github.com/blevesearch/zap/v14 v14.0.0 h1:HF8Ysjm13qxB0jTGaKLlatNXmJbQD8bY+PrPxm5v4hE= +github.com/blevesearch/zap/v14 v14.0.0/go.mod h1:sUc/gPGJlFbSQ2ZUh/wGRYwkKx+Dg/5p+dd+eq6QMXk= github.com/bmatcuk/doublestar v1.1.1/go.mod h1:UD6OnuiIn0yFxxA2le/rnRU1G4RaI4UvFv1sNto9p6w= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY= github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= @@ -153,18 +175,30 @@ github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.17+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/etcd v3.3.18+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-oidc v2.1.0+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/couchbase/ghistogram v0.1.0/go.mod h1:s1Jhy76zqfEecpNWJfWUiKZookAFaiGOEoyzgHt9i7k= +github.com/couchbase/moss v0.1.0/go.mod h1:9MaHIaRuy9pvLPUJxB8sh8OrLfyDczECVL37grCIubs= +github.com/couchbase/vellum v1.0.1 h1:qrj9ohvZedvc51S5KzPfJ6P6z0Vqzv7Lx7k3mVc2WOk= +github.com/couchbase/vellum v1.0.1/go.mod h1:FcwrEivFpNi24R3jLOs3n+fs5RnuQnQqCLBJ1uAg1W4= github.com/cpu/goacmedns v0.0.1/go.mod h1:sesf/pNnCYwUevQEQfEwY0Y3DydlQWSGZbaMElOWxok= +github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d h1:SwD98825d6bdB+pEuTxWOXiSjBrHdOl/UVp75eI7JT8= +github.com/cznic/b v0.0.0-20181122101859-a26611c4d92d/go.mod h1:URriBxXwVq5ijiJ12C7iIZqlA69nTlI+LgI6/pwftG8= +github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548 h1:iwZdTE0PVqJCos1vaoKsclOGD3ADKpshg3SRtYBbwso= +github.com/cznic/mathutil v0.0.0-20181122101859-297441e03548/go.mod h1:e6NPNENfs9mPDVNRekM7lKScauxd5kXTr1Mfyig6TDM= +github.com/cznic/strutil v0.0.0-20181122101858-275e90344537 h1:MZRmHqDBd0vxNwenEbKSQqRVT24d3C05ft8kduSwlqM= +github.com/cznic/strutil v0.0.0-20181122101858-275e90344537/go.mod h1:AHHPPPXTw0h6pVabbcbyGRK1DckRn7r/STdZEeIDzZc= github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -198,6 +232,12 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/evanphx/json-patch v4.2.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= github.com/evanphx/json-patch/v5 v5.0.0/go.mod h1:G79N1coSVB93tBe7j6PhzjmR3/2VvlbKOFpnXhI9Bw4= github.com/exoscale/egoscale v0.18.1/go.mod h1:Z7OOdzzTOz1Q1PjQXumlz9Wn/CddH0zSYdCF3rnBKXE= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= +github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= @@ -215,7 +255,11 @@ github.com/gizak/termui/v3 v3.1.0/go.mod h1:bXQEBkJpzxUAKf0+xq9MSWAvWZlE7c+aidmy github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2 h1:Ujru1hufTHVb++eG6OuNDKMxZnGIvF6o/u8q/8h2+I4= +github.com/glycerine/go-unsnap-stream v0.0.0-20181221182339-f9677308dec2/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= github.com/glycerine/goconvey v0.0.0-20180728074245-46e3a41ad493/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31 h1:gclg6gY70GLy3PbkQ1AERPfmLMMagS60DKF78eWwLn8= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= github.com/go-acme/lego/v3 v3.1.0/go.mod h1:074uqt+JS6plx+c9Xaiz6+L+GBb+7itGtzfcDM2AhEE= github.com/go-acme/lego/v3 v3.3.0/go.mod h1:iGSY2vQrvQs3WezicSB/oVbO2eCrD88dpWPwb1qLqu0= github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= @@ -295,6 +339,7 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1 h1:ZFgWrT+bLgsYPirOnRfKLYJLvssAegOj/hgyMFdJZe0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/gomodule/redigo v2.0.0+incompatible/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4= github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -328,6 +373,7 @@ github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1a github.com/gophercloud/gophercloud v0.3.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gopherjs/gopherjs v0.0.0-20190910122728-9d188e94fb99/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -394,12 +440,15 @@ github.com/iij/doapi v0.0.0-20190504054126-0bbf12d6d7df/go.mod h1:QMZY7/J/KSQEhK github.com/ijc/Gotty v0.0.0-20170406111628-a8b993ba6abd/go.mod h1:3LVOLeyx9XVvwPgrt2be44XgSqndprz1G18rSk8KD84= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= +github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc= github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -426,6 +475,7 @@ github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQL github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/kljensen/snowball v0.6.0/go.mod h1:27N7E8fVU5H68RlUmnWwZCfxgt4POBJfENGMvNRhldw= github.com/kolo/xmlrpc v0.0.0-20190717152603-07c4ee3fd181/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= @@ -450,6 +500,7 @@ github.com/liquidweb/liquidweb-go v1.6.0/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVL github.com/lucas-clemente/quic-go v0.12.1/go.mod h1:UXJJPE4RfFef/xPO5wQm0tITK8gNfqwTxjbE7s3Vb8s= github.com/lucas-clemente/quic-go v0.13.1/go.mod h1:Vn3/Fb0/77b02SGhQk36KzOUmXgVpFfizUfW5WMaqyU= github.com/lucas-clemente/quic-go v0.14.1/go.mod h1:Vn3/Fb0/77b02SGhQk36KzOUmXgVpFfizUfW5WMaqyU= +github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20180730094502-03f2033d19d5/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= @@ -517,6 +568,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= +github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= +github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= @@ -591,6 +644,7 @@ github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTK github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-buffruneio v0.2.0/go.mod h1:JkE26KsDizTr40EUHkXVtNPvgGtbSNq5BcowyYOWdKo= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/philhofer/fwd v1.0.0 h1:UbZqGr5Y38ApvM/V/jEljVxwocdweyH+vmYvRPBnbqQ= github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -630,6 +684,9 @@ github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDa github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKcyumwBO6qip7RNQ5r77yrssm9bfCowcLEBcU5IA= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 h1:OdAsTTz6OkFY5QxjkYwrChwuRruF69c169dPK26NUlk= +github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/restic/calens v0.1.0/go.mod h1:u67f5msOjCTDYNzOf/NoAUSdmXP03YXPCwIQLYADy5M= github.com/restic/calens v0.2.0 h1:LVNAtmFc+Pb4ODX66qdX1T3Di1P0OTLyUsVyvM/xD7E= github.com/restic/calens v0.2.0/go.mod h1:UXwyAKS4wsgUZGEc7NrzzygJbLsQZIo3wl+62Q1wvmU= @@ -639,6 +696,7 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.17.2/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I= +github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -668,14 +726,18 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= github.com/spf13/viper v1.6.1/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k= github.com/spf13/viper v1.6.3 h1:pDDu1OyEDTKzpJwdq4TiuLyMsUgRa/BT5cn5O62NoHs= github.com/spf13/viper v1.6.3/go.mod h1:jUMtyi0/lB5yZH/FjyGAoH7IMNrIhlBf6pXZmbMDvzw= github.com/src-d/gcfg v1.4.0/go.mod h1:p/UMsR43ujA89BJY9duynAwIpvqEujIH/jFlfL7jWoI= +github.com/steveyen/gtreap v0.1.0 h1:CjhzTa274PyJLJuMZwIzCO1PfC00oRa8d1Kc78bFXJM= +github.com/steveyen/gtreap v0.1.0/go.mod h1:kl/5J7XbrOmlIbYIXdRHDDE5QxHqpk0cmkT7Z4dM9/Y= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -689,9 +751,14 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stvp/tempredis v0.0.0-20181119212430-b82af8480203/go.mod h1:oqN97ltKNihBbwlX8dLpwxCl3+HnXKV/R0e+sRLd9C8= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/syndtr/gocapability v0.0.0-20170704070218-db04d3cc01c8/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= +github.com/syndtr/goleveldb v1.0.0 h1:fBdIW9lB4Iz0n9khmH8w27SJ3QEJ7+IgjPEwGSZiFdE= +github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= +github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= github.com/technoweenie/multipartstreamer v1.0.1/go.mod h1:jNVxdtShOxzAsukZwTSw6MDx5eUJoiEBsSvzDU9uzog= github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7/go.mod h1:imsgLplxEC/etjIhdr3dNzV3JeT27LbVu5pYWm0JCBY= github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= +github.com/tinylib/msgp v1.1.0 h1:9fQd+ICuRIu/ue4vxJZu6/LzxN0HwMds2nq/0cFvxHU= github.com/tinylib/msgp v1.1.0/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20200122045848-3419fae592fc h1:yUaosFVTJwnltaHbSNC3i82I92quFs+OFPRl8kNMVwo= @@ -701,12 +768,15 @@ github.com/transip/gotransip v0.0.0-20190812104329-6d8d9179b66f/go.mod h1:i0f4R4 github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g= github.com/uber/jaeger-client-go v2.15.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= +github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw= github.com/vultr/govultr v0.1.4/go.mod h1:9H008Uxr/C4vFNGLqKx232C206GL0PBHzOP0809bGNA= github.com/willf/bitset v1.1.9/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= +github.com/willf/bitset v1.1.10 h1:NotGKqX0KwQ72NUzqrjZq5ipPNDQex9lo3WpaS8L2sc= +github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/xanzy/ssh-agent v0.2.1 h1:TCbipTQL2JiiCprBWx9frJ2eJlCYT00NmctrHxVAr70= github.com/xanzy/ssh-agent v0.2.1/go.mod h1:mLlQY/MoOhWBj+gOGMQkOeiEvkx+8pJSI+0Bx9h2kr4= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= @@ -850,6 +920,8 @@ golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5h golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190129075346-302c3dd5f1cc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190130150945-aca44879d564/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190209173611-3b5209105503/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -871,6 +943,7 @@ golang.org/x/sys v0.0.0-20190710143415-6ec70d6a5542/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190801041406-cbf593c0f2f3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -994,7 +1067,6 @@ gopkg.in/jcmturner/dnsutils.v1 v1.0.1/go.mod h1:m3v+5svpVOhtFAP/wSz+yzh4Mc0Fg7eR gopkg.in/jcmturner/goidentity.v3 v3.0.0/go.mod h1:oG2kH0IvSYNIu80dVAyu/yoefjq1mNfM5bm88whjWx4= gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuvyavf11/WM= gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= -gopkg.in/ldap.v2 v2.5.1/go.mod h1:oI0cpe/D7HRtBQl8aTg+ZmzFUAvu4lsv3eLXMLGFxWk= gopkg.in/ldap.v3 v3.1.0/go.mod h1:dQjCc0R0kfyFjIlWNMH1DORwUASZyDxo2Ry1B51dXaQ= gopkg.in/ns1/ns1-go.v2 v2.0.0-20190730140822-b51389932cbc/go.mod h1:VV+3haRsgDiVLxyifmMBrBIuCWFBPYKbRssXB9z67Hw= gopkg.in/olivere/elastic.v5 v5.0.82/go.mod h1:uhHoB4o3bvX5sorxBU29rPcmBQdV2Qfg0FBrx5D6pV0= diff --git a/pkg/config/config.go b/pkg/config/config.go index 00db2bf77..2cafaddae 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -26,9 +26,10 @@ type LDAPSchema struct { // Server configures a server. type Server struct { - Name string - Namespace string - Address string + Name string + Namespace string + Address string + AccountsDataPath string } // Log defines the available logging configuration. diff --git a/pkg/flagset/flagset.go b/pkg/flagset/flagset.go index a4b9f08bc..3be48c473 100644 --- a/pkg/flagset/flagset.go +++ b/pkg/flagset/flagset.go @@ -61,104 +61,13 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { EnvVars: []string{"ACCOUNTS_ADDRESS"}, Destination: &cfg.Server.Address, }, - // LDAP - &cli.StringFlag{ - Name: "ldap-hostname", - Value: "localhost", - Usage: "LDAP hostname", - EnvVars: []string{"ACCOUNTS_LDAP_HOSTNAME"}, - Destination: &cfg.LDAP.Hostname, - }, - &cli.IntFlag{ - Name: "ldap-port", - Value: 9126, - Usage: "LDAP port", - EnvVars: []string{"ACCOUNTS_LDAP_PORT"}, - Destination: &cfg.LDAP.Port, - }, - &cli.StringFlag{ - Name: "ldap-base-dn", - Value: "dc=example,dc=org", - Usage: "LDAP basedn", - EnvVars: []string{"ACCOUNTS_LDAP_BASE_DN"}, - Destination: &cfg.LDAP.BaseDN, - }, - &cli.StringFlag{ - Name: "ldap-userfilter", - Value: "(&(objectclass=posixAccount)(cn=%s))", - Usage: "LDAP userfilter", - EnvVars: []string{"ACCOUNTS_LDAP_USERFILTER"}, - Destination: &cfg.LDAP.UserFilter, - }, - &cli.StringFlag{ - Name: "ldap-groupfilter", - Value: "(&(objectclass=posixGroup)(cn=%s))", - Usage: "LDAP groupfilter", - EnvVars: []string{"ACCOUNTS_LDAP_GROUPFILTER"}, - Destination: &cfg.LDAP.GroupFilter, - }, - &cli.StringFlag{ - Name: "ldap-bind-dn", - Value: "cn=reva,ou=sysusers,dc=example,dc=org", - Usage: "LDAP bind dn", - EnvVars: []string{"ACCOUNTS_LDAP_BIND_DN"}, - Destination: &cfg.LDAP.BindDN, - }, - &cli.StringFlag{ - Name: "ldap-bind-password", - Value: "reva", - Usage: "LDAP bind password", - EnvVars: []string{"ACCOUNTS_LDAP_BIND_PASSWORD"}, - Destination: &cfg.LDAP.BindPassword, - }, - &cli.StringFlag{ - Name: "ldap-idp", - Value: "https://localhost:9200", - Usage: "Identity provider to use for users", - EnvVars: []string{"ACCOUNTS_LDAP_IDP"}, - Destination: &cfg.LDAP.IDP, - }, - // ldap dn is always the dn - &cli.StringFlag{ - Name: "ldap-schema-account-id", - // TODO write down LDAP schema & register OID ownclouduuid - //... use 'sourceAnchor','immutableid' see https://docs.microsoft.com/en-us/azure/active-directory/hybrid/plan-connect-design-concepts#sourceanchor - // or 'ms-DS-ConsistencyGuid' see https://docs.microsoft.com/en-us/azure/active-directory/hybrid/plan-connect-design-concepts - // or build a scim schema for ldap? https://ldapwiki.com/wiki/SCIM%20Common%20Attribute - // glauth -> support id and externalid from scim - Value: "uidNumber", - Usage: "LDAP schema account id", - EnvVars: []string{"ACCOUNTS_LDAP_SCHEMA_ACCOUNT_ID"}, - Destination: &cfg.LDAP.Schema.AccountID, - }, - &cli.StringFlag{ - Name: "ldap-schema-username", - Value: "uid", - Usage: "LDAP schema username", - EnvVars: []string{"ACCOUNTS_LDAP_SCHEMA_USERNAME"}, - Destination: &cfg.LDAP.Schema.Username, - }, - &cli.StringFlag{ - Name: "ldap-schema-displayName", - Value: "sn", - Usage: "LDAP schema displayName", - EnvVars: []string{"ACCOUNTS_LDAP_SCHEMA_DISPLAYNAME"}, - Destination: &cfg.LDAP.Schema.DisplayName, - }, - &cli.StringFlag{ - Name: "ldap-schema-mail", - Value: "mail", - Usage: "LDAP schema mail", - EnvVars: []string{"ACCOUNTS_LDAP_SCHEMA_MAIL"}, - Destination: &cfg.LDAP.Schema.Mail, - }, - &cli.StringFlag{ - Name: "ldap-schema-cn", - Value: "memberof", - Usage: "LDAP schema cn", - EnvVars: []string{"ACCOUNTS_LDAP_SCHEMA_GROUPS"}, - Destination: &cfg.LDAP.Schema.Groups, + Name: "accounts-data-path", + Value: "/var/tmp/ocis-accounts", + DefaultText: "/var/tmp/ocis-accounts", + Usage: "accounts folder", + EnvVars: []string{"ACCOUNTS_DATA_PATH"}, + Destination: &cfg.Server.AccountsDataPath, }, } } diff --git a/pkg/provider/bleve.go b/pkg/provider/bleve.go new file mode 100644 index 000000000..bfad79477 --- /dev/null +++ b/pkg/provider/bleve.go @@ -0,0 +1,98 @@ +package provider + +import ( + "errors" + + "github.com/CiscoM31/godata" + "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/search/query" +) + +func init() { + // add (ap)prox filter + godata.GlobalFilterTokenizer = FilterTokenizer() + godata.GlobalFilterParser.DefineOperator("ap", 2, godata.OpAssociationLeft, 4, false) +} + +// BuildBleveQuery converts a GoDataFilterQuery into a bleve query +func BuildBleveQuery(r *godata.GoDataFilterQuery) (query.Query, error) { + return recursiveBuildQuery(r.Tree) +} + +// Builds the filter recursively using DFS +func recursiveBuildQuery(n *godata.ParseNode) (query.Query, error) { + if n.Token.Type == godata.FilterTokenFunc { + switch n.Token.Value { + case "startswith": + if len(n.Children) != 2 { + return nil, errors.New("startswith match must have two children") + } + if n.Children[0].Token.Type != godata.FilterTokenLiteral { + return nil, errors.New("startswith expected a literal as the first param") + } + if n.Children[1].Token.Type != godata.FilterTokenString { + return nil, errors.New("startswith expected a string as the second param") + } + q := bleve.NewTermQuery(n.Children[1].Token.Value) + q.SetField(n.Children[0].Token.Value) + return q, nil + default: + return nil, godata.NotImplementedError(n.Token.Value + " is not implemented.") + } + } + if n.Token.Type == godata.FilterTokenLogical { + switch n.Token.Value { + case "eq": + if len(n.Children) != 2 { + return nil, errors.New("Equality match must have two children") + } + if n.Children[0].Token.Type != godata.FilterTokenLiteral { + return nil, errors.New("Equality expected a literal on the lhs") + } + if n.Children[1].Token.Type != godata.FilterTokenString { + return nil, errors.New("Equality expected a string on the rhs") + } + q := bleve.NewTermQuery(n.Children[1].Token.Value) + q.SetField(n.Children[0].Token.Value) + return q, nil + case "and": + q := query.NewConjunctionQuery([]query.Query{}) + for _, child := range n.Children { + subQuery, err := recursiveBuildQuery(child) + if err != nil { + return nil, err + } + if subQuery != nil { + q.AddQuery(subQuery) + } + } + return q, nil + case "or": + q := query.NewDisjunctionQuery([]query.Query{}) + for _, child := range n.Children { + subQuery, err := recursiveBuildQuery(child) + if err != nil { + return nil, err + } + if subQuery != nil { + q.AddQuery(subQuery) + } + } + return q, nil + case "Not": + if len(n.Children) != 1 { + return nil, errors.New("Not filter must have only one child") + } + subQuery, err := recursiveBuildQuery(n.Children[0]) + if err != nil { + return nil, err + } + q := query.NewBooleanQuery(nil, nil, []query.Query{subQuery}) + return q, nil + default: + return nil, godata.NotImplementedError(n.Token.Value + " is not implemented.") + } + } + + return nil, godata.NotImplementedError(n.Token.Value + " is not implemented.") +} diff --git a/pkg/provider/ldap.go b/pkg/provider/ldap.go deleted file mode 100644 index 5454ba99e..000000000 --- a/pkg/provider/ldap.go +++ /dev/null @@ -1,180 +0,0 @@ -package provider - -import ( - "fmt" - "strings" - - "github.com/CiscoM31/godata" - "github.com/owncloud/ocis-accounts/pkg/config" - "gopkg.in/ldap.v2" -) - -func init() { - // add (ap)prox filter - godata.GlobalFilterTokenizer = FilterTokenizer() - godata.GlobalFilterParser.DefineOperator("ap", 2, godata.OpAssociationLeft, 4, false) -} - -// LDAPNodeMap is used to convert query tokens into ldap filters according to https://tools.ietf.org/search/rfc4515 -var LDAPNodeMap = map[string]string{ - // 11.2.6.1.1 Built-in Filter Operations according to http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#_Toc31358949 - - // Comparison Operators - "eq": "(%s=%s)", // -> LDAP equal - "ne": "(!(%s=%s))", // -> LDAP NOT equal - //"gt": "(&(%s>=%s)(!(%s=%s)))", // -> TODO can be constructed but requires more parameters - "ge": "(%s>=%s)", // -> LDAP greaterorequal - //"lt": "(&(%s<=%s)(!(%s=%s)))", // -> TODO can be constructed but requires more parameters - "le": "(%s<=%s)", // -> LDAP lessorequal - //"has": "(%s=*)", // -> TODO LDAP present but in odata has looks like "Style has Sales.Color'Yellow'" - //"in": "???", // TODO - - // additional native LDAP Search String Filter Definition according to https://tools.ietf.org/search/rfc4515#section-3 - "ap": "(%s~=%s)", // approx, TODO needs token in parser, odata uses $search instead of $filter for fuzzy search - - // Logical Operators - // While LDAP understands logical filters like (&()()()()) we leave that as an optimization and use at max two params - "and": "(&%s%s)", - "or": "(|%s%s)", - "not": "(!%s)", - - // Arithmetic operators - //"add": "" - //"sub": "" - //"mul": "" - //"div": "" - //"divby": "" - //"mod": "" - - // Grouping operators - - // 11.2.6.1.2 Built-in Query Functions according to http://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#sec_BuiltinQueryFunctions - //String and Collection Functions - //"concat": "CONCAT(%s,%s)", - "contains": "(%s=*%s*)", - "endswith": "(%s=*%s)", - //"indexof": "LOCATE(%s)", - //"length": "LENGTH(%s)", - "startswith": "(%s=%s*)", - //"substring": "", - - // - //"tolower": "LOWER(%s)", - //"toupper": "UPPER(%s)", - //"trim": "TRIM(%s)", - //"year": "YEAR(%s)", - //"month": "MONTH(%s)", - //"day": "DAY(%s)", - //"hour": "HOUR(%s)", - //"minute": "MINUTE(%s)", - //"second": "SECOND(%s)", - //"fractionalsecond": "MICROSECOND(%s)", - //"date": "DATE(%s)", - //"time": "TIME(%s)", - //"totaloffsetminutes": "", - //"now": "NOW()", - //"maxdatetime":"", - //"mindatetime":"", - //"totalseconds":"", - //"round": "ROUND(%s)", - //"floor": "FLOOR(%s)", - //"ceiling": "CEIL(%s)", - //"isof": "", // TODO objectclass= - //"cast": "", - //"geo.distance": "", - //"geo.intersects": "", - //"geo.length": "", - //"any": "", - //"all": "", - //"null": "NULL", -} - -// BuildLDAPFilter converts a GoDataFilterQuery into an ldap filter -func BuildLDAPFilter(r *godata.GoDataFilterQuery, c *config.LDAPSchema) (string, error) { - return recursiveBuildFilter(r.Tree, c) -} - -// Builds the filter recursively using DFS -func recursiveBuildFilter(n *godata.ParseNode, c *config.LDAPSchema) (string, error) { - if n.Token.Type == godata.FilterTokenLiteral { - switch n.Token.Value { - case "accountid": - return c.AccountID, nil - case "displayname": - return c.DisplayName, nil - case "username": - return c.Username, nil - case "mail": - return c.Mail, nil - case "groups": - // TODO groups - return "", godata.NotImplementedError(n.Token.Value + " is not implemented.") - case "identities": - // TODO identities - return "", godata.NotImplementedError(n.Token.Value + " is not implemented.") - } - return "", godata.BadRequestError("unknown property " + n.Token.Value) - } - if n.Token.Type == godata.FilterTokenString { - // without leading and ending ' required by odata - // encode LDAP safe - return strings.TrimSuffix(strings.TrimPrefix(ldap.EscapeFilter(n.Token.Value), "'"), "'"), nil - } - if n.Token.Type == godata.FilterTokenInteger { - return n.Token.Value, nil - } - if n.Token.Type == godata.FilterTokenFloat { - return n.Token.Value, nil - } - - if v, ok := LDAPNodeMap[n.Token.Value]; ok { - children := []interface{}{} - // build each child first using DFS - for _, child := range n.Children { - f, err := recursiveBuildFilter(child, c) - if err != nil { - return "", err - } - children = append(children, f) - } - // merge together the children and the current node - result := fmt.Sprintf(v, children...) - return result, nil - } - return "", godata.NotImplementedError(n.Token.Value + " is not implemented.") -} - -// FilterTokenizer creates a tokenizer capable of tokenizing filter statements -// TODO disable tokens we don't handle anyway -func FilterTokenizer() *godata.Tokenizer { - t := godata.Tokenizer{} - t.Add("^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}T[0-9]{2,2}:[0-9]{2,2}(:[0-9]{2,2}(.[0-9]+)?)?(Z|[+-][0-9]{2,2}:[0-9]{2,2})", godata.FilterTokenDateTime) - t.Add("^-?[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}", godata.FilterTokenDate) - t.Add("^[0-9]{2,2}:[0-9]{2,2}(:[0-9]{2,2}(.[0-9]+)?)?", godata.FilterTokenTime) - t.Add("^\\(", godata.FilterTokenOpenParen) - t.Add("^\\)", godata.FilterTokenCloseParen) - t.Add("^/", godata.FilterTokenNav) - t.Add("^:", godata.FilterTokenColon) - t.Add("^,", godata.FilterTokenComma) - t.Add("^(geo.distance|geo.intersects|geo.length)", godata.FilterTokenFunc) - t.Add("^(substringof|substring|length|indexof)", godata.FilterTokenFunc) - // only change from the global tokenizer is the added ap - t.Add("^(eq|ne|gt|ge|lt|le|and|or|not|has|in|ap)", godata.FilterTokenLogical) - t.Add("^(add|sub|mul|divby|div|mod)", godata.FilterTokenOp) - t.Add("^(contains|endswith|startswith|tolower|toupper|"+ - "trim|concat|year|month|day|hour|minute|second|fractionalseconds|date|"+ - "time|totaloffsetminutes|now|maxdatetime|mindatetime|totalseconds|round|"+ - "floor|ceiling|isof|cast)", godata.FilterTokenFunc) - t.Add("^(any|all)", godata.FilterTokenLambda) - t.Add("^null", godata.FilterTokenNull) - t.Add("^\\$it", godata.FilterTokenIt) - t.Add("^\\$root", godata.FilterTokenRoot) - t.Add("^-?[0-9]+\\.[0-9]+", godata.FilterTokenFloat) - t.Add("^-?[0-9]+", godata.FilterTokenInteger) - t.Add("^'(''|[^'])*'", godata.FilterTokenString) - t.Add("^(true|false)", godata.FilterTokenBoolean) - t.Add("^@*[a-zA-Z][a-zA-Z0-9_.]*", godata.FilterTokenLiteral) // The optional '@' character is used to identify parameter aliases - t.Ignore("^ ", godata.FilterTokenWhitespace) - - return &t -} diff --git a/pkg/provider/ldap_test.go b/pkg/provider/ldap_test.go deleted file mode 100644 index efc67b4e3..000000000 --- a/pkg/provider/ldap_test.go +++ /dev/null @@ -1,68 +0,0 @@ -package provider - -import ( - "testing" - - "github.com/CiscoM31/godata" - "github.com/owncloud/ocis-accounts/pkg/config" -) - -var c *config.LDAPSchema - -func init() { - c = &config.LDAPSchema{ - AccountID: "ownclouduuid", - Username: "uid", - Mail: "mail", - DisplayName: "displayname", - } -} - -func TestEQ(t *testing.T) { testLDAPFilters(t, "accountid eq 'a-b-c-d'", "(ownclouduuid=a-b-c-d)") } -func TestNE(t *testing.T) { testLDAPFilters(t, "mail ne 'foo@bar.com'", "(!(mail=foo@bar.com))") } -func TestGE(t *testing.T) { testLDAPFilters(t, "displayname ge 'marie'", "(displayname>=marie)") } -func TestLE(t *testing.T) { testLDAPFilters(t, "username le 'marie'", "(uid<=marie)") } - -//func TestHas(t *testing.T) { testLDAPFilters(t, "Style has Sales.Color'Yellow'", "(foo=*)") } -func TestAP(t *testing.T) { - testLDAPFilters(t, "displayname ap 'einstein'", "(displayname~=einstein)") -} -func TestAND(t *testing.T) { - testLDAPFilters(t, "accountid le 500000 and accountid ge 300000", "(&(ownclouduuid<=500000)(ownclouduuid>=300000))") -} -func TestOR(t *testing.T) { - testLDAPFilters(t, "accountid le 700000 or accountid ge 900000", "(|(ownclouduuid<=700000)(ownclouduuid>=900000))") -} -func TestNOT(t *testing.T) { - // not operator takes precedence over ap, so we need brackets - testLDAPFilters(t, "not ( displayname ap 'einstein' )", "(!(displayname~=einstein))") -} -func TestContains(t *testing.T) { - testLDAPFilters(t, "contains(username,'eins')", "(uid=*eins*)") -} -func TestStartsWith(t *testing.T) { - testLDAPFilters(t, "startswith(username,'eins')", "(uid=eins*)") -} -func TestEndsWith(t *testing.T) { - testLDAPFilters(t, "endswith(username,'eins')", "(uid=*eins)") -} -func TestEncoding(t *testing.T) { - testLDAPFilters(t, "displayname eq 'eins(*)tein'", "(displayname=eins\\28\\2a\\29tein)") -} - -func testLDAPFilters(t *testing.T, have string, want string) { - - var err error - - var q *godata.GoDataFilterQuery - if q, err = godata.ParseFilterString(have); err != nil { - t.Error(err) - } - var filter string - if filter, err = BuildLDAPFilter(q, c); err != nil { - t.Error(err) - } - if filter != want { - t.Error("expected", want, "for", have, "but got", filter) - } -} diff --git a/pkg/provider/tokenizer.go b/pkg/provider/tokenizer.go new file mode 100644 index 000000000..f4d7c59ef --- /dev/null +++ b/pkg/provider/tokenizer.go @@ -0,0 +1,38 @@ +package provider + +import "github.com/CiscoM31/godata" + +// FilterTokenizer creates a tokenizer capable of tokenizing filter statements +// TODO disable tokens we don't handle anyway +func FilterTokenizer() *godata.Tokenizer { + t := godata.Tokenizer{} + t.Add("^[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}T[0-9]{2,2}:[0-9]{2,2}(:[0-9]{2,2}(.[0-9]+)?)?(Z|[+-][0-9]{2,2}:[0-9]{2,2})", godata.FilterTokenDateTime) + t.Add("^-?[0-9]{4,4}-[0-9]{2,2}-[0-9]{2,2}", godata.FilterTokenDate) + t.Add("^[0-9]{2,2}:[0-9]{2,2}(:[0-9]{2,2}(.[0-9]+)?)?", godata.FilterTokenTime) + t.Add("^\\(", godata.FilterTokenOpenParen) + t.Add("^\\)", godata.FilterTokenCloseParen) + t.Add("^/", godata.FilterTokenNav) + t.Add("^:", godata.FilterTokenColon) + t.Add("^,", godata.FilterTokenComma) + t.Add("^(geo.distance|geo.intersects|geo.length)", godata.FilterTokenFunc) + t.Add("^(substringof|substring|length|indexof)", godata.FilterTokenFunc) + // only change from the global tokenizer is the added ap + t.Add("^(eq|ne|gt|ge|lt|le|and|or|not|has|in|ap)", godata.FilterTokenLogical) + t.Add("^(add|sub|mul|divby|div|mod)", godata.FilterTokenOp) + t.Add("^(contains|endswith|startswith|tolower|toupper|"+ + "trim|concat|year|month|day|hour|minute|second|fractionalseconds|date|"+ + "time|totaloffsetminutes|now|maxdatetime|mindatetime|totalseconds|round|"+ + "floor|ceiling|isof|cast)", godata.FilterTokenFunc) + t.Add("^(any|all)", godata.FilterTokenLambda) + t.Add("^null", godata.FilterTokenNull) + t.Add("^\\$it", godata.FilterTokenIt) + t.Add("^\\$root", godata.FilterTokenRoot) + t.Add("^-?[0-9]+\\.[0-9]+", godata.FilterTokenFloat) + t.Add("^-?[0-9]+", godata.FilterTokenInteger) + t.Add("^'(''|[^'])*'", godata.FilterTokenString) + t.Add("^(true|false)", godata.FilterTokenBoolean) + t.Add("^@*[a-zA-Z][a-zA-Z0-9_.]*", godata.FilterTokenLiteral) // The optional '@' character is used to identify parameter aliases + t.Ignore("^ ", godata.FilterTokenWhitespace) + + return &t +} diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index 5d868566f..b61b71046 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -2,12 +2,16 @@ package service import ( "context" - "crypto/tls" + "encoding/json" "errors" - "fmt" + "io/ioutil" + "os" + "path/filepath" "regexp" "github.com/CiscoM31/godata" + "github.com/blevesearch/bleve" + "github.com/blevesearch/bleve/search/query" "github.com/golang/protobuf/ptypes/empty" mclient "github.com/micro/go-micro/v2/client" "github.com/owncloud/ocis-accounts/pkg/config" @@ -16,13 +20,55 @@ import ( olog "github.com/owncloud/ocis-pkg/v2/log" settings "github.com/owncloud/ocis-settings/pkg/proto/v0" "github.com/rs/zerolog/log" - "gopkg.in/ldap.v2" ) // New returns a new instance of Service func New(cfg *config.Config) Service { + // read all user and group records + + // for now recreate index on every start + os.RemoveAll(filepath.Join(cfg.Server.AccountsDataPath, "index.bleve")) + os.MkdirAll(filepath.Join(cfg.Server.AccountsDataPath, "accounts"), 0700) + + mapping := bleve.NewIndexMapping() + // TODO don't bother to store fields as we will load the account from disk + index, err := bleve.New(filepath.Join(cfg.Server.AccountsDataPath, "index.bleve"), mapping) + if err != nil { + panic(err) + } + f, err := os.Open(filepath.Join(cfg.Server.AccountsDataPath, "accounts")) + if err != nil { + log.Error().Err(err).Str("dir", filepath.Join(cfg.Server.AccountsDataPath, "accounts")).Msg("could not open acconts folder") + panic(err) + } + list, err := f.Readdir(-1) + f.Close() + if err != nil { + log.Error().Err(err).Str("dir", filepath.Join(cfg.Server.AccountsDataPath, "accounts")).Msg("could not list accounts folder") + panic(err) + } + for _, file := range list { + path := filepath.Join(cfg.Server.AccountsDataPath, "accounts", file.Name()) + data, err := ioutil.ReadFile(path) + if err != nil { + log.Error().Err(err).Str("path", path).Msg("could not read account") + continue + } + a := proto.Account{} + err = json.Unmarshal(data, &a) + if err != nil { + log.Error().Err(err).Str("path", path).Msg("could not unmarshal account") + continue + } + log.Debug().Interface("account", a).Msg("found account") + index.Index(a.Id, a) + } + + // TODO watch folders for new records + s := Service{ Config: cfg, + index: index, } return s @@ -31,53 +77,7 @@ func New(cfg *config.Config) Service { // Service implements the AccountsServiceHandler interface type Service struct { Config *config.Config -} - -func (s Service) getBoundConnection(binddn string, password string) (l *ldap.Conn, err error) { - l, err = ldap.DialTLS("tcp", fmt.Sprintf("%s:%d", s.Config.LDAP.Hostname, s.Config.LDAP.Port), &tls.Config{InsecureSkipVerify: true}) - if err != nil { - return nil, err - } - - err = l.Bind(binddn, password) - if err != nil { - l.Close() - return nil, err - } - - return -} - -func (s Service) lookupDN(username string) (binddn string, err error) { - l, err := s.getBoundConnection(s.Config.LDAP.BindDN, s.Config.LDAP.BindPassword) - if err != nil { - return "", err - } - defer l.Close() - - filter := fmt.Sprintf("(%s=%s)", s.Config.LDAP.Schema.Username, ldap.EscapeFilter(username)) - - // Search for the given username - searchRequest := ldap.NewSearchRequest( - s.Config.LDAP.BaseDN, - ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, - filter, - []string{"dn"}, - nil, - ) - - sr, err := l.Search(searchRequest) - if err != nil { - return "", err - } - - switch len(sr.Entries) { - case 0: // TODO return not found error - case 1: - return sr.Entries[0].DN, nil - default: // TODO return too many results error? - } - return "", fmt.Errorf("dn not found for %s", filter) + index bleve.Index } // the auth request is currently hardcoded and has to macth this regex @@ -89,82 +89,50 @@ var authQuery = regexp.MustCompile(`^username eq '(.*)' and password eq '(.*)'$` // TODO id vs onpremiseimmutableid func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest, res *proto.ListAccountsResponse) (err error) { - var binddn string - var password string - - // check if this looks like an auth request - match := authQuery.FindStringSubmatch(in.Query) - if len(match) == 3 { - - binddn, err = s.lookupDN(match[1]) - if err != nil { - log.Error().Err(err).Msg("ListAccounts with auth request") - return - } - log.Debug().Str("username", match[1]).Str("binddn", binddn).Msg("ListAccounts with auth request") - - password = match[2] - // remove password from query - in.Query = fmt.Sprintf("username eq '%s'", match[1]) - } else { - log.Debug().Str("query", in.Query).Int32("page-size", in.PageSize).Str("page-token", in.PageToken).Msg("ListAccounts") - binddn = s.Config.LDAP.BindDN - password = s.Config.LDAP.BindPassword - } - - filter := "(&)" // see Absolute True and False Filters in https://tools.ietf.org/html/rfc4526#section-2 + var query query.Query if in.Query != "" { // parse the query like an odata filter var q *godata.GoDataFilterQuery if q, err = godata.ParseFilterString(in.Query); err != nil { + log.Error().Err(err).Msg("could not parse query") return } - // convert to ldap filter - filter, err = provider.BuildLDAPFilter(q, &s.Config.LDAP.Schema) + // convert to bleve query + query, err = provider.BuildBleveQuery(q) if err != nil { + log.Error().Err(err).Msg("could not build bleve query") return } + } else { + query = bleve.NewMatchAllQuery() } - log.Debug().Str("filter", filter).Msg("using filter") + log.Debug().Interface("query", query).Msg("using query") - var l *ldap.Conn - l, err = s.getBoundConnection(binddn, password) - if err != nil { - return - } - defer l.Close() - - // TODO combine the parsed query with a query filter from the config, eg. fmt.Sprintf(s.Config.LDAP.UserFilter, clientID) - - // Search for the given clientID - searchRequest := ldap.NewSearchRequest( - s.Config.LDAP.BaseDN, - ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, - filter, - []string{"dn", s.Config.LDAP.Schema.AccountID, s.Config.LDAP.Schema.Username, s.Config.LDAP.Schema.DisplayName, s.Config.LDAP.Schema.Mail, s.Config.LDAP.Schema.Groups}, // TODO Groups, Identities? - nil, - ) - - sr, err := l.Search(searchRequest) - if err != nil { - return err - } - - log.Debug().Interface("entries", sr.Entries).Msg("entries") + searchRequest := bleve.NewSearchRequest(query) + searchResult, err := s.index.Search(searchRequest) + log.Debug().Interface("result", searchResult).Msg("result") res.Accounts = make([]*proto.Account, 0) - for i := range sr.Entries { - res.Accounts = append(res.Accounts, &proto.Account{ - Id: sr.Entries[i].GetAttributeValue(s.Config.LDAP.Schema.AccountID), - // TODO identities - Username: sr.Entries[i].GetAttributeValue(s.Config.LDAP.Schema.Username), - DisplayName: sr.Entries[i].GetAttributeValue(s.Config.LDAP.Schema.DisplayName), - Mail: sr.Entries[i].GetAttributeValue(s.Config.LDAP.Schema.Mail), - //Groups: sr.Entries[i].GetAttributeValues(s.Config.LDAP.Schema.Groups), - }) + + for _, hit := range searchResult.Hits { + path := filepath.Join(s.Config.Server.AccountsDataPath, "accounts", hit.ID) + + data, err := ioutil.ReadFile(path) + if err != nil { + log.Error().Err(err).Str("path", path).Msg("could not read account") + continue + } + a := proto.Account{} + err = json.Unmarshal(data, &a) + if err != nil { + log.Error().Err(err).Str("path", path).Msg("could not unmarshal account") + continue + } + log.Debug().Interface("account", a).Msg("found account") + res.Accounts = append(res.Accounts, &a) } return nil @@ -172,45 +140,7 @@ func (s Service) ListAccounts(ctx context.Context, in *proto.ListAccountsRequest // GetAccount implements the AccountsServiceHandler interface func (s Service) GetAccount(c context.Context, req *proto.GetAccountRequest, res *proto.Account) (err error) { - - l, err := s.getBoundConnection(s.Config.LDAP.BindDN, s.Config.LDAP.BindPassword) - if err != nil { - return err - } - defer l.Close() - - // TODO combine the parsed query with a query filter from the config, eg. fmt.Sprintf(s.Config.LDAP.UserFilter, clientID) - filter := fmt.Sprintf("(%s=%s)", s.Config.LDAP.Schema.AccountID, ldap.EscapeFilter(req.Id)) - - // Search for the given clientID - searchRequest := ldap.NewSearchRequest( - s.Config.LDAP.BaseDN, - ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false, - filter, - []string{"dn", s.Config.LDAP.Schema.AccountID, s.Config.LDAP.Schema.Username, s.Config.LDAP.Schema.DisplayName, s.Config.LDAP.Schema.Mail, s.Config.LDAP.Schema.Groups}, // TODO Groups, Identities? - nil, - ) - - sr, err := l.Search(searchRequest) - if err != nil { - return err - } - - log.Debug().Interface("entries", sr.Entries).Msg("entries") - - switch len(sr.Entries) { - case 0: // TODO return not found error - case 1: - res.Id = sr.Entries[0].GetAttributeValue(s.Config.LDAP.Schema.AccountID) - // TODO identities? - res.Username = sr.Entries[0].GetAttributeValue(s.Config.LDAP.Schema.Username) - res.DisplayName = sr.Entries[0].GetAttributeValue(s.Config.LDAP.Schema.DisplayName) - res.Mail = sr.Entries[0].GetAttributeValue(s.Config.LDAP.Schema.Mail) - // TODO groups - default: // TODO return too many results error? - } - - return nil + return errors.New("not implemented") } // CreateAccount implements the AccountsServiceHandler interface