Skip to content

Commit eb4e2d8

Browse files
author
David Christofas
authored
Merge pull request #2831 from owncloud/public-link-signature-auth
enable signature auth in public share auth middleware
2 parents 0369de0 + a85644c commit eb4e2d8

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: Support signature auth in the public share auth middleware
2+
3+
Enabled public share requests to be authenticated using the public share signature.
4+
5+
https://github.com/owncloud/ocis/pull/2831

proxy/pkg/middleware/public_share_auth.go

+17-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package middleware
22

33
import (
44
"net/http"
5+
"strings"
56

67
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
78
)
@@ -32,12 +33,23 @@ func PublicShareAuth(opts ...Option) func(next http.Handler) http.Handler {
3233
return
3334
}
3435

35-
// We can ignore the username since it is always set to "public" in public shares.
36-
_, password, ok := r.BasicAuth()
36+
var sharePassword string
37+
if signature := r.URL.Query().Get("signature"); signature != "" {
38+
expiration := r.URL.Query().Get("expiration")
39+
if expiration == "" {
40+
logger.Warn().Str("signature", signature).Msg("cannot do signature auth without the expiration")
41+
next.ServeHTTP(w, r)
42+
return
43+
}
44+
sharePassword = strings.Join([]string{"signature", signature, expiration}, "|")
45+
} else {
46+
// We can ignore the username since it is always set to "public" in public shares.
47+
_, password, ok := r.BasicAuth()
3748

38-
sharePassword := basicAuthPasswordPrefix
39-
if ok {
40-
sharePassword += password
49+
sharePassword = basicAuthPasswordPrefix
50+
if ok {
51+
sharePassword += password
52+
}
4153
}
4254

4355
authResp, err := options.RevaGatewayClient.Authenticate(r.Context(), &gateway.AuthenticateRequest{

0 commit comments

Comments
 (0)