Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serve: add s3 server #6461

Closed
wants to merge 14 commits into from
Closed
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ fuzz-build.zip
*.rej
Thumbs.db
__pycache__
.devcontainer
.DS_Store
8 changes: 8 additions & 0 deletions backend/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ func init() {
}, {
Value: "RackCorp",
Help: "RackCorp Object Storage",
}, {
Value: "Rclone",
Help: "Rclone S3 Server",
}, {
Value: "Scaleway",
Help: "Scaleway Object Storage",
Expand Down Expand Up @@ -2612,6 +2615,11 @@ func setQuirks(opt *Options) {
listObjectsV2 = false // untested
virtualHostStyle = false
urlEncodeListings = false
case "Rclone":
listObjectsV2 = true
urlEncodeListings = true
virtualHostStyle = false
useMultipartEtag = false
case "Storj":
// Force chunk size to >= 64 MiB
if opt.ChunkSize < 64*fs.Mebi {
Expand Down
25 changes: 25 additions & 0 deletions cmd/serve/s3/auth.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package s3

import (
"net/http"

"github.com/rclone/rclone/cmd/serve/s3/signature"
)

func (p *Server) authMiddleware(handler http.Handler) http.Handler {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to make the auth proxy work with this server?

https://github.com/rclone/rclone/blob/master/cmd/serve/proxy/proxy.go

return http.HandlerFunc(func(w http.ResponseWriter, rq *http.Request) {

// first pass to auth handler
if Opt.authPair != "" {
if result := signature.Verify(rq); result != signature.ErrNone {
resp := signature.GetAPIError(result)
w.WriteHeader(resp.HTTPStatusCode)
w.Header().Add("content-type", "application/xml")
_, _ = w.Write(signature.EncodeAPIErrorToResponse(resp))
return
}
}

handler.ServeHTTP(w, rq)
})
}