mirror of
https://github.com/restic/rest-server.git
synced 2025-10-19 15:43:21 +00:00
htpasswd file relative to repo
This commit is contained in:
parent
738e78c439
commit
ff5e60135c
2 changed files with 5 additions and 3 deletions
6
auth.go
6
auth.go
|
@ -3,11 +3,13 @@ package main
|
|||
import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func Authorize(r *http.Request) error {
|
||||
func Authorize(r *http.Request, c *Context) error {
|
||||
|
||||
htpasswd, err := NewHtpasswdFromFile("/tmp/restic/.htpasswd")
|
||||
file := filepath.Join(c.path, ".htpasswd")
|
||||
htpasswd, err := NewHtpasswdFromFile(file)
|
||||
if err != nil {
|
||||
return errors.New("internal server error")
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ func (router Router) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
log.Printf("%s %s", m, u)
|
||||
|
||||
if err := Authorize(r); err == nil {
|
||||
if err := Authorize(r, &router.Context); err == nil {
|
||||
if handler := RestAPI(m, u); handler != nil {
|
||||
handler(w, r, &router.Context)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue