Fix some minor issues with authentication and qbit auth
This commit is contained in:
@@ -147,10 +147,9 @@ func (q *QBit) authenticate(category, username, password string) (*arr.Arr, erro
|
|||||||
a.Host = username
|
a.Host = username
|
||||||
a.Token = password
|
a.Token = password
|
||||||
arrValidated := false // This is a flag to indicate if arr validation was successful
|
arrValidated := false // This is a flag to indicate if arr validation was successful
|
||||||
if a.Host == "" || a.Token == "" && cfg.UseAuth {
|
if (a.Host == "" || a.Token == "") && cfg.UseAuth {
|
||||||
return nil, fmt.Errorf("unauthorized: Host and token are required for authentication(you've enabled authentication)")
|
return nil, fmt.Errorf("unauthorized: Host and token are required for authentication(you've enabled authentication)")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := a.Validate(); err == nil {
|
if err := a.Validate(); err == nil {
|
||||||
arrValidated = true
|
arrValidated = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
"github.com/go-chi/chi/v5/middleware"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"github.com/sirrobot01/decypharr/internal/config"
|
"github.com/sirrobot01/decypharr/internal/config"
|
||||||
"github.com/sirrobot01/decypharr/internal/logger"
|
"github.com/sirrobot01/decypharr/internal/logger"
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
@@ -24,6 +25,8 @@ func New(handlers map[string]http.Handler) *Server {
|
|||||||
l := logger.New("http")
|
l := logger.New("http")
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
r.Use(middleware.Recoverer)
|
r.Use(middleware.Recoverer)
|
||||||
|
r.Use(middleware.StripSlashes)
|
||||||
|
r.Use(middleware.RedirectSlashes)
|
||||||
|
|
||||||
cfg := config.Get()
|
cfg := config.Get()
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-chi/chi/v5"
|
"github.com/go-chi/chi/v5"
|
||||||
"github.com/go-chi/chi/v5/middleware"
|
|
||||||
"github.com/sirrobot01/decypharr/internal/config"
|
"github.com/sirrobot01/decypharr/internal/config"
|
||||||
"github.com/sirrobot01/decypharr/internal/utils"
|
"github.com/sirrobot01/decypharr/internal/utils"
|
||||||
"github.com/sirrobot01/decypharr/pkg/wire"
|
"github.com/sirrobot01/decypharr/pkg/wire"
|
||||||
@@ -74,9 +73,8 @@ func New() *WebDav {
|
|||||||
|
|
||||||
func (wd *WebDav) Routes() http.Handler {
|
func (wd *WebDav) Routes() http.Handler {
|
||||||
wr := chi.NewRouter()
|
wr := chi.NewRouter()
|
||||||
wr.Use(middleware.StripSlashes)
|
|
||||||
wr.Use(wd.commonMiddleware)
|
wr.Use(wd.commonMiddleware)
|
||||||
// wr.Use(wd.authMiddleware) Disable auth for now
|
//wr.Use(wd.authMiddleware) Disable auth for now
|
||||||
|
|
||||||
wd.setupRootHandler(wr)
|
wd.setupRootHandler(wr)
|
||||||
wd.mountHandlers(wr)
|
wd.mountHandlers(wr)
|
||||||
|
|||||||
Reference in New Issue
Block a user