mirror of
https://github.com/rclone/rclone.git
synced 2025-08-23 11:32:03 +02:00
cmd: add support for private repositories in serve restic
- fixes #3247
This commit is contained in:
committed by
Nick Craig-Wood
parent
64fb4effa7
commit
939b19c3b7
@@ -2,6 +2,7 @@
|
||||
package httplib
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
@@ -114,6 +115,11 @@ type Server struct {
|
||||
HTMLTemplate *template.Template // HTML template for web interface
|
||||
}
|
||||
|
||||
type contextUserType struct{}
|
||||
|
||||
// ContextUserKey is a simple context key
|
||||
var ContextUserKey = &contextUserType{}
|
||||
|
||||
// singleUserProvider provides the encrypted password for a single user
|
||||
func (s *Server) singleUserProvider(user, realm string) string {
|
||||
if user == s.Opt.BasicUser {
|
||||
@@ -172,6 +178,7 @@ func NewServer(handler http.Handler, opt *Options) *Server {
|
||||
}
|
||||
authenticator.RequireAuth(w, r)
|
||||
} else {
|
||||
r = r.WithContext(context.WithValue(r.Context(), ContextUserKey, username))
|
||||
oldHandler.ServeHTTP(w, r)
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user