Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Commit

Permalink
Merge pull request #5 from owncloud/improve_wopiserver
Browse files Browse the repository at this point in the history
improve wopiserver
  • Loading branch information
wkloucek authored May 27, 2021
2 parents 57ecdaa + abf275a commit b4935f5
Show file tree
Hide file tree
Showing 12 changed files with 340 additions and 242 deletions.
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,21 @@ require (
contrib.go.opencensus.io/exporter/ocagent v0.7.0
contrib.go.opencensus.io/exporter/zipkin v0.1.2
github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/cs3org/go-cs3apis v0.0.0-20210507060801-f176760d55f4
github.com/cs3org/reva v1.7.1-0.20210507160327-e2c3841d0dbc
github.com/go-chi/chi v4.1.2+incompatible
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/micro/cli/v2 v2.1.2
github.com/oklog/run v1.1.0
github.com/openzipkin/zipkin-go v0.2.5
github.com/owncloud/ocis/ocis-pkg v0.0.0-20210414075100-f98347d8418d
github.com/owncloud/ocis/ocis-pkg v0.0.0-20210519113029-34a8ed381620
github.com/prometheus/client_golang v1.10.0
github.com/spf13/viper v1.7.1
go.opencensus.io v0.23.0
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781
google.golang.org/genproto v0.0.0-20210413151531-c14fb6ef47c3 // indirect
google.golang.org/grpc v1.37.0
)

replace (
Expand Down
38 changes: 27 additions & 11 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"email": "support@owncloud.com"
},
"scripts": {
"lint": "eslint ui/**/*.vue ui/**/*.js --color --global requirejs --global require",
"lint": "eslint ui/**/*.js --color --global requirejs --global require",
"build": "rollup -c",
"watch": "rollup -c -w",
"test": "echo 'Not implemented'",
Expand Down
6 changes: 3 additions & 3 deletions pkg/assets/embed.go

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ type TokenManager struct {
}

type WopiServer struct {
Host string
Secret string
Insecure bool
Host string
Secret string
Insecure bool
RevaGateway string
}

// Config combines all available configuration parts.
Expand Down
14 changes: 14 additions & 0 deletions pkg/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,19 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag {
EnvVars: []string{"WOPISERVER_WOPI_SERVER_INSECURE"},
Destination: &cfg.WopiServer.Insecure,
},
&cli.StringFlag{
Name: "jwt-secret",
Value: flags.OverrideDefaultString(cfg.TokenManager.JWTSecret, "Pive-Fumkiu4"),
Usage: "Used to create JWT to talk to reva, should equal reva's jwt-secret",
EnvVars: []string{"WOPISERVER_JWT_SECRET", "OCIS_JWT_SECRET"},
Destination: &cfg.TokenManager.JWTSecret,
},
&cli.StringFlag{
Name: "reva-gateway-addr",
Value: flags.OverrideDefaultString(cfg.WopiServer.RevaGateway, "127.0.0.1:9142"),
Usage: "Reva gateway address",
EnvVars: []string{"WOPISERVER_REVA_GATEWAY_ADDR"},
Destination: &cfg.WopiServer.RevaGateway,
},
}
}
13 changes: 13 additions & 0 deletions pkg/server/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package http

import (
"github.com/asim/go-micro/v3"
"github.com/cs3org/reva/pkg/rgrpc/todo/pool"
svc "github.com/owncloud/ocis-wopiserver/pkg/service/v0"
"github.com/owncloud/ocis-wopiserver/pkg/version"
"github.com/owncloud/ocis/ocis-pkg/account"
"github.com/owncloud/ocis/ocis-pkg/middleware"
"github.com/owncloud/ocis/ocis-pkg/service/http"
)
Expand All @@ -22,6 +24,12 @@ func Server(opts ...Option) (http.Service, error) {
http.Flags(options.Flags...),
)

gc, err := pool.GetGatewayServiceClient(options.Config.WopiServer.RevaGateway)
if err != nil {
options.Logger.Error().Err(err).Msg("could not get gateway client")
return http.Service{}, err
}

handle := svc.NewService(
svc.Logger(options.Logger),
svc.Config(options.Config),
Expand All @@ -31,6 +39,10 @@ func Server(opts ...Option) (http.Service, error) {
middleware.NoCache,
middleware.Cors,
middleware.Secure,
middleware.ExtractAccountUUID(
account.Logger(options.Logger),
account.JWTSecret(options.Config.TokenManager.JWTSecret),
),
middleware.Version(
"wopiserver",
version.String,
Expand All @@ -39,6 +51,7 @@ func Server(opts ...Option) (http.Service, error) {
options.Logger,
),
),
svc.CS3Client(gc),
)

{
Expand Down
8 changes: 8 additions & 0 deletions pkg/service/v0/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package svc
import (
"net/http"

gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
"github.com/owncloud/ocis-wopiserver/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/log"
)
Expand All @@ -15,6 +16,7 @@ type Options struct {
Logger log.Logger
Config *config.Config
Middleware []func(http.Handler) http.Handler
CS3Client gateway.GatewayAPIClient
}

// newOptions initializes the available default options.
Expand Down Expand Up @@ -48,3 +50,9 @@ func Middleware(val ...func(http.Handler) http.Handler) Option {
o.Middleware = val
}
}

func CS3Client(c gateway.GatewayAPIClient) Option {
return func(o *Options) {
o.CS3Client = c
}
}
Loading

0 comments on commit b4935f5

Please sign in to comment.