-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce ocdav NewWithConfig() Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add go micro service wrapper for ocdav Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add changelog Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * make jwtsecret configurable Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add header and missing loader Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * add doc for the ocdav cmd Signed-off-by: Jörn Friedrich Dreyer <jfd@butonic.de> * liniting issues Signed-off-by: jkoberg <jkoberg@owncloud.com> * minor cleanup Signed-off-by: jkoberg <jkoberg@owncloud.com> * tracing Signed-off-by: jkoberg <jkoberg@owncloud.com> * Revert "minor cleanup" This reverts commit f501bd3. * trying to understand why the test is failing Signed-off-by: jkoberg <jkoberg@owncloud.com> * still trying to understand why the test is failing Signed-off-by: jkoberg <jkoberg@owncloud.com> * fix the typo Signed-off-by: jkoberg <jkoberg@owncloud.com> * reorder middlewares Signed-off-by: jkoberg <jkoberg@owncloud.com> Co-authored-by: jkoberg <jkoberg@owncloud.com>
- Loading branch information
Showing
9 changed files
with
481 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Enhancement: Add embeddable ocdav go micro service | ||
|
||
The new `pkg/micro/ocdav` package implements a go micro compatible version of the ocdav service. | ||
|
||
https://github.com/cs3org/reva/pull/2665 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright 2018-2021 CERN | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// In applying this license, CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
package main | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/cs3org/reva/v2/pkg/micro/ocdav" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
// main starts a go micro service that uses the ocdev handler | ||
// It is an example how to use pkg/micro/ocdav Service and leaves out any flag parsing. | ||
func main() { | ||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix | ||
logger := zerolog.New(os.Stdout).With().Timestamp().Logger() | ||
|
||
s, err := ocdav.Service( | ||
ocdav.Logger(logger), | ||
ocdav.GatewaySvc("127.0.0.1:9142"), | ||
ocdav.FilesNamespace("/users/{{.Id.OpaqueId}}"), | ||
ocdav.WebdavNamespace("/users/{{.Id.OpaqueId}}"), | ||
ocdav.SharesNamespace("/Shares"), | ||
) | ||
if err != nil { | ||
logger.Fatal().Err(err).Msg("failed starting ocdav service") | ||
return | ||
} | ||
if err := s.Run(); err != nil { | ||
logger.Fatal().Err(err).Msg("ocdav service exited with error") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright 2018-2021 CERN | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// In applying this license, CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
package ocdav | ||
|
||
import ( | ||
// initialize reva registries by importing the relevant loader packages | ||
// see cmd/revad/runtime/loader.go for other loaders if a service is not found | ||
_ "github.com/cs3org/reva/v2/internal/http/interceptors/auth/credential/loader" | ||
_ "github.com/cs3org/reva/v2/internal/http/interceptors/auth/token/loader" | ||
_ "github.com/cs3org/reva/v2/internal/http/interceptors/auth/tokenwriter/loader" | ||
_ "github.com/cs3org/reva/v2/pkg/token/manager/loader" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
// Copyright 2018-2021 CERN | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// In applying this license, CERN does not waive the privileges and immunities | ||
// granted to it by virtue of its status as an Intergovernmental Organization | ||
// or submit itself to any jurisdiction. | ||
|
||
package ocdav | ||
|
||
import ( | ||
"context" | ||
"crypto/tls" | ||
|
||
"github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav" | ||
"github.com/cs3org/reva/v2/pkg/storage/favorite" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
// Option defines a single option function. | ||
type Option func(o *Options) | ||
|
||
// Options defines the available options for this package. | ||
type Options struct { | ||
TLSConfig *tls.Config | ||
Address string | ||
Logger zerolog.Logger | ||
Context context.Context | ||
// Metrics *metrics.Metrics | ||
// Flags []cli.Flag | ||
Name string | ||
JWTSecret string | ||
|
||
FavoriteManager favorite.Manager | ||
|
||
TracingEnabled bool | ||
TracingCollector string | ||
TracingEndpoint string | ||
|
||
// ocdav.* is internal so we need to set config options individually | ||
config ocdav.Config | ||
lockSystem ocdav.LockSystem | ||
} | ||
|
||
// newOptions initializes the available default options. | ||
func newOptions(opts ...Option) Options { | ||
opt := Options{} | ||
|
||
for _, o := range opts { | ||
o(&opt) | ||
} | ||
|
||
return opt | ||
} | ||
|
||
// TLSConfig provides a function to set the TLSConfig option. | ||
func TLSConfig(config *tls.Config) Option { | ||
return func(o *Options) { | ||
o.TLSConfig = config | ||
} | ||
} | ||
|
||
// Address provides a function to set the address option. | ||
func Address(val string) Option { | ||
return func(o *Options) { | ||
o.Address = val | ||
} | ||
} | ||
|
||
// JWTSecret provides a function to set the jwt secret option. | ||
func JWTSecret(s string) Option { | ||
return func(o *Options) { | ||
o.JWTSecret = s | ||
} | ||
} | ||
|
||
// Context provides a function to set the context option. | ||
func Context(val context.Context) Option { | ||
return func(o *Options) { | ||
o.Context = val | ||
} | ||
} | ||
|
||
// Logger provides a function to set the logger option. | ||
func Logger(val zerolog.Logger) Option { | ||
return func(o *Options) { | ||
o.Logger = val | ||
} | ||
} | ||
|
||
// Name provides a function to set the Name option. | ||
func Name(val string) Option { | ||
return func(o *Options) { | ||
o.Name = val | ||
} | ||
} | ||
|
||
// Prefix provides a function to set the prefix config option. | ||
func Prefix(val string) Option { | ||
return func(o *Options) { | ||
o.config.Prefix = val | ||
} | ||
} | ||
|
||
// FilesNamespace provides a function to set the FilesNamespace config option. | ||
func FilesNamespace(val string) Option { | ||
return func(o *Options) { | ||
o.config.FilesNamespace = val | ||
} | ||
} | ||
|
||
// WebdavNamespace provides a function to set the WebdavNamespace config option. | ||
func WebdavNamespace(val string) Option { | ||
return func(o *Options) { | ||
o.config.WebdavNamespace = val | ||
} | ||
} | ||
|
||
// SharesNamespace provides a function to set the SharesNamespace config option. | ||
func SharesNamespace(val string) Option { | ||
return func(o *Options) { | ||
o.config.SharesNamespace = val | ||
} | ||
} | ||
|
||
// GatewaySvc provides a function to set the GatewaySvc config option. | ||
func GatewaySvc(val string) Option { | ||
return func(o *Options) { | ||
o.config.GatewaySvc = val | ||
} | ||
} | ||
|
||
// Timeout provides a function to set the Timeout config option. | ||
func Timeout(val int64) Option { | ||
return func(o *Options) { | ||
o.config.Timeout = val | ||
} | ||
} | ||
|
||
// Insecure provides a function to set the Insecure config option. | ||
func Insecure(val bool) Option { | ||
return func(o *Options) { | ||
o.config.Insecure = val | ||
} | ||
} | ||
|
||
// PublicURL provides a function to set the PublicURL config option. | ||
func PublicURL(val string) Option { | ||
return func(o *Options) { | ||
o.config.PublicURL = val | ||
} | ||
} | ||
|
||
// FavoriteManager provides a function to set the FavoriteManager option. | ||
func FavoriteManager(val favorite.Manager) Option { | ||
return func(o *Options) { | ||
o.FavoriteManager = val | ||
} | ||
} | ||
|
||
// LockSystem provides a function to set the LockSystem option. | ||
func LockSystem(val ocdav.LockSystem) Option { | ||
return func(o *Options) { | ||
o.lockSystem = val | ||
} | ||
} | ||
|
||
// Tracing enables tracing | ||
func Tracing(trEndpoint string, trCollector string) Option { | ||
return func(o *Options) { | ||
o.TracingEnabled = true | ||
o.TracingEndpoint = trEndpoint | ||
o.TracingCollector = trCollector | ||
} | ||
} |
Oops, something went wrong.