chore: Add readme file and adjust configuration for better defaults

This commit is contained in:
Juan Pablo Villafáñez
2024-04-17 15:54:50 +02:00
parent 3e90402350
commit ecc235bbec
10 changed files with 41 additions and 18 deletions
+2 -2
View File
@@ -14,7 +14,7 @@ type Config struct {
Service Service `yaml:"-"`
App App `yaml:"app"`
Secret string `yaml:"secret" env:"COLLABORATION_SECRET" desc:"Used as JWT token and to encrypt access token."`
JWTSecret string `yaml:"jwt_secret" env:"OCIS_JWT_SECRET;COLLABORATION_JWT_SECRET" desc:"Used as JWT token and to encrypt access token."`
GRPC GRPC `yaml:"grpc"`
HTTP HTTP `yaml:"http"`
@@ -23,7 +23,7 @@ type Config struct {
Tracing *Tracing `yaml:"tracing"`
Log *Log `yaml:"log"`
Debug Debug `yaml:"debug"`
//Debug Debug `yaml:"debug"`
Context context.Context `yaml:"-"`
}
+2 -2
View File
@@ -7,9 +7,9 @@ type CS3Api struct {
}
type Gateway struct {
Name string `yaml: "name" env:"COLLABORATION_CS3API_GATEWAY_NAME" desc:"service name of the CS3API gateway"`
Name string `yaml: "name" env:"COLLABORATION_CS3API_GATEWAY_NAME" desc:"The service name of the CS3API gateway."`
}
type DataGateway struct {
Insecure bool `yaml:"insecure" env:"COLLABORATION_CS3API_DATAGATEWAY_INSECURE" desc:"connect to the CS3API data gateway insecurely"`
Insecure bool `yaml:"insecure" env:"COLLABORATION_CS3API_DATAGATEWAY_INSECURE" desc:"Connect to the CS3API data gateway insecurely."`
}
@@ -25,26 +25,27 @@ func DefaultConfig() *config.Config {
Icon: "image-edit",
LockName: "com.github.owncloud.collaboration",
},
Secret: uniuri.NewLen(32),
JWTSecret: uniuri.NewLen(32),
GRPC: config.GRPC{
Addr: "127.0.0.1:56778",
Addr: "0.0.0.0:9301",
Namespace: "com.owncloud.collaboration",
},
HTTP: config.HTTP{
Addr: "127.0.0.1:6789",
Addr: "127.0.0.1:9300",
BindAddr: "0.0.0.0:9300",
Namespace: "com.owncloud.collaboration",
//Scheme: "http",
Scheme: "https",
},
WopiApp: config.WopiApp{
Addr: "https://127.0.0.1:8080",
Insecure: true, // TODO: this should have a secure default
Insecure: false,
},
CS3Api: config.CS3Api{
Gateway: config.Gateway{
Name: "com.owncloud.api.gateway",
},
DataGateway: config.DataGateway{
Insecure: true, // TODO: this should have a secure default
Insecure: false,
},
},
}
+1 -1
View File
@@ -6,7 +6,7 @@ import (
// HTTP defines the available http configuration.
type HTTP struct {
Addr string `yaml:"addr" env:"COLLABORATION_HTTP_ADDR" desc:"The address of the HTTP service."`
Addr string `yaml:"addr" env:"COLLABORATION_HTTP_ADDR" desc:"The external address of the HTTP service. Either IP address or host (127.0.0.1:9301 or wopi.private.prv). The configured "Scheme" will be used to build public URLs along with this address."`
BindAddr string `yaml:"bindaddr" env:"COLLABORATION_HTTP_BINDADDR" desc:"The bind address of the HTTP service."`
Namespace string `yaml:"-"`
Scheme string `yaml:"scheme" env:"COLLABORATION_HTTP_SCHEME" desc:"Either http or https"`
+1 -1
View File
@@ -3,5 +3,5 @@ package config
// WopiApp defines the available configuration in order to connect to a WOPI app.
type WopiApp struct {
Addr string `yaml:"addr" env:"COLLABORATION_WOPIAPP_ADDR" desc:"The URL where the WOPI app is located, such as https://127.0.0.1:8080."`
Insecure bool `yaml:"insecure" env:"COLLABORATION_WOPIAPP_INSECURE" desc:"Connect insecurely"`
Insecure bool `yaml:"insecure" env:"COLLABORATION_WOPIAPP_INSECURE" desc:"Connect to the WOPI app insecurely."`
}
@@ -45,7 +45,7 @@ func WopiContextAuthMiddleware(app *DemoApp, next http.Handler) http.Handler {
return nil, fmt.Errorf("unexpected signing method: %v", token.Header["alg"])
}
return []byte(app.Config.Secret), nil
return []byte(app.Config.JWTSecret), nil
})
if err != nil {
@@ -62,7 +62,7 @@ func WopiContextAuthMiddleware(app *DemoApp, next http.Handler) http.Handler {
ctx := r.Context()
wopiContextAccessToken, err := DecryptAES([]byte(app.Config.Secret), claims.WopiContext.AccessToken)
wopiContextAccessToken, err := DecryptAES([]byte(app.Config.JWTSecret), claims.WopiContext.AccessToken)
if err != nil {
fmt.Println("wopicontext", err)
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
@@ -48,7 +48,7 @@ func Server(opts ...Option) (http.Service, error) {
),
middleware.ExtractAccountUUID(
account.Logger(options.Logger),
account.JWTSecret(options.Config.Secret), // previously, secret came from Config.TokenManager.JWTSecret
account.JWTSecret(options.Config.JWTSecret), // previously, secret came from Config.TokenManager.JWTSecret
),
/*
// Need CORS? not in the original server
@@ -148,7 +148,7 @@ func (s *Service) OpenInApp(
appURL = editAppURL
}
cryptedReqAccessToken, err := app.EncryptAES([]byte(s.config.Secret), req.AccessToken)
cryptedReqAccessToken, err := app.EncryptAES([]byte(s.config.JWTSecret), req.AccessToken)
if err != nil {
s.logger.Error().
Err(err).
@@ -191,7 +191,7 @@ func (s *Service) OpenInApp(
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
accessToken, err := token.SignedString([]byte(s.config.Secret))
accessToken, err := token.SignedString([]byte(s.config.JWTSecret))
if err != nil {
s.logger.Error().