Skip to content

Commit 4655321

Browse files
committed
remove hardcoded placeholder signing key
1 parent 91a4961 commit 4655321

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

internal/http/services/owncloud/ocdav/trashbin.go

-5
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,6 @@ func (h *TrashbinHandler) handleTrashbinSpaces(s *svc, w http.ResponseWriter, r
7777
key, r.URL.Path = router.ShiftPath(r.URL.Path)
7878
if key != "" && r.Method == MethodMove {
7979
// find path in url relative to trash base
80-
// trashBase := ctx.Value(ctxKeyBaseURI).(string)
81-
// baseURI := path.Join(path.Dir(trashBase), "files", username)
82-
// ctx = context.WithValue(ctx, ctxKeyBaseURI, baseURI)
83-
// r = r.WithContext(ctx)
84-
8580
// TODO make request.php optional in destination header
8681
dst, err := extractDestination(r)
8782
if err != nil {

internal/http/services/owncloud/ocs/config/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type Config struct {
4747
ListOCMShares bool `mapstructure:"list_ocm_shares"`
4848
Notifications map[string]interface{} `mapstructure:"notifications"`
4949
EnableSpaces bool `mapstructure:"enable_spaces"`
50+
SigningKey string `mapstructure:"signing_key"`
5051
}
5152

5253
// Init sets sane defaults.

internal/http/services/owncloud/ocs/handlers/cloud/user/user.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,21 @@ import (
3939
type Handler struct {
4040
gatewayAddr string
4141
allowedLanguages []string
42+
signingKey string
4243
}
4344

4445
// Init initializes this and any contained handlers.
45-
func (h *Handler) Init(c *config.Config) {
46+
func (h *Handler) Init(c *config.Config) error {
47+
if len(c.SigningKey) < 32 {
48+
return errors.New("Please set a signing key with an appropriate length")
49+
}
4650
h.gatewayAddr = c.GatewaySvc
4751
h.allowedLanguages = c.AllowedLanguages
52+
h.signingKey = c.SigningKey
4853
if len(h.allowedLanguages) == 0 {
4954
h.allowedLanguages = []string{"cs", "de", "en", "es", "fr", "it", "gl"}
5055
}
56+
return nil
5157
}
5258

5359
const (
@@ -85,7 +91,7 @@ func (h *Handler) SigningKey(w http.ResponseWriter, r *http.Request) {
8591

8692
response.WriteOCSSuccess(w, r, &SigningKey{
8793
User: u.Username,
88-
SigningKey: "UGFyY2UgbWVybywgY29lbmF0byBwYXJ1bTogbm9uIHNpdCB0aWJpIHZhbnVtClN1cmdlcmUgcG9zdCBlcHVsYXM6IHNvbW51bSBmdWdlIG1lcmlkaWFudW06Ck5vbiBtaWN0dW0gcmV0aW5lLCBuZWMgY29tcHJpbWUgZm9ydGl0ZXIgYW51bS4KSGFlYyBiZW5lIHNpIHNlcnZlcywgdHUgbG9uZ28gdGVtcG9yZSB2aXZlcw==",
94+
SigningKey: h.signingKey,
8995
})
9096
}
9197

0 commit comments

Comments
 (0)