Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Dashbrr provides real-time monitoring, service health checks, and unified manage
- **Autobrr**: IRC network health, release statistics
- **Prowlarr**: Indexer health monitoring
- **Maintainerr**: Rule matching, scheduled deletion monitoring
- **Omegabrr**: Service health, manual ARR triggers

### Network

Expand Down
12 changes: 9 additions & 3 deletions cmd/dashbrr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (

"github.com/autobrr/dashbrr/internal/api"
"github.com/autobrr/dashbrr/internal/buildinfo"
"github.com/autobrr/dashbrr/internal/cache"
"github.com/autobrr/dashbrr/internal/commands"
"github.com/autobrr/dashbrr/internal/config"
"github.com/autobrr/dashbrr/internal/database"
"github.com/autobrr/dashbrr/internal/logger"
"github.com/autobrr/dashbrr/internal/services"
"github.com/autobrr/dashbrr/internal/services/cache"

"github.com/pkg/errors"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -160,6 +160,7 @@ func startServer(configPath string, listenAddr string, origDBPath string) error
ctx := context.Background()

// Initialize cache with database directory for session storage
// TODO read from cfg
cacheConfig := cache.Config{
DataDir: filepath.Dir(os.Getenv("DASHBRR__DB_PATH")), // Use same directory as database
Type: cache.CacheTypeMemory,
Expand Down Expand Up @@ -189,9 +190,14 @@ func startServer(configPath string, listenAddr string, origDBPath string) error
return err
}

healthService := services.NewHealthService()
serviceManager := services.NewServiceManager(db, store)
if err := serviceManager.InitializeServices(ctx); err != nil {
log.Error().Err(err).Msg("Failed to initialize services")
}

serviceManager.StartHealthMonitor()

srv := api.NewServer(cfg, db, store, healthService)
srv := api.NewServer(cfg, db, store, serviceManager)

errorChannel := make(chan error)
go func() {
Expand Down
15 changes: 0 additions & 15 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,21 +151,6 @@ Example: dashbrr service maintainerr remove http://localhost:7476
dashbrr service maintainerr list
```

### Omegabrr

```bash
# Add an Omegabrr service
dashbrr service omegabrr add <url> <api-key>
Example: dashbrr service omegabrr add http://localhost:7477 your-api-key

# Remove an Omegabrr service
dashbrr service omegabrr remove <url>
Example: dashbrr service omegabrr remove http://localhost:7477

# List Omegabrr services
dashbrr service omegabrr list
```

### Overseerr

```bash
Expand Down
1 change: 0 additions & 1 deletion docs/config_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ When using environment variables for API keys (${SERVICE_API_KEY}), the followin
- `DASHBRR_TAILSCALE_API_KEY`
- `DASHBRR_PLEX_API_KEY`
- `DASHBRR_AUTOBRR_API_KEY`
- `DASHBRR_OMEGABRR_API_KEY`

## Security Considerations

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ require (
github.com/docker/docker v27.3.1+incompatible
github.com/gin-contrib/cors v1.7.2
github.com/gin-gonic/gin v1.10.0
github.com/go-redis/redis/v8 v8.11.5
github.com/lib/pq v1.10.9
github.com/pelletier/go-toml/v2 v2.2.3
github.com/pkg/errors v0.9.1
github.com/redis/go-redis/v9 v9.7.0
github.com/rs/zerolog v1.33.0
github.com/spf13/cobra v1.8.1
github.com/stretchr/testify v1.9.0
Expand Down
16 changes: 6 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ github.com/Masterminds/squirrel v1.5.4 h1:uUcX/aBc8O7Fg9kaISIUsHXdKuqehiXAMQTYX8
github.com/Masterminds/squirrel v1.5.4/go.mod h1:NNaOrjSoIDfDA40n7sr2tPNZRfjzjA400rg+riTZj10=
github.com/Microsoft/go-winio v0.4.14 h1:+hMXMk01us9KgxGb7ftKQt2Xpf5hH/yky+TDA+qxleU=
github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA=
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
github.com/bytedance/sonic v1.12.3 h1:W2MGa7RCU1QTeYRTPE3+88mVC0yXmsRQRChiyVocVjU=
github.com/bytedance/sonic v1.12.3/go.mod h1:B8Gt/XvtZ3Fqj+iSKMypzymZxw/FVwgIGKzMzT9r/rk=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
Expand Down Expand Up @@ -44,8 +48,6 @@ github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxER
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
github.com/gabriel-vasile/mimetype v1.4.6 h1:3+PzJTKLkvgjeTbts6msPJt4DixhT4YtFNf1gtGe3zc=
Expand Down Expand Up @@ -76,8 +78,6 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.22.1 h1:40JcKH+bBNGFczGuoBYgX4I6m/i27HYW8P9FDk5PbgA=
github.com/go-playground/validator/v10 v10.22.1/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
Expand Down Expand Up @@ -156,10 +156,6 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
github.com/onsi/ginkgo/v2 v2.19.0 h1:9Cnnf7UHo57Hy3k6/m5k3dRfGTMXGvxhHFvkDTCTpvA=
github.com/onsi/ginkgo/v2 v2.19.0/go.mod h1:rlwLi9PilAFJ8jCg9UE1QP6VBpd6/xj3SRC0d6TU0To=
github.com/onsi/gomega v1.19.0 h1:4ieX6qQjPP/BfC3mpsAtIGGlxTWPeA3Inl/7DtXw1tw=
Expand All @@ -176,6 +172,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
Expand Down Expand Up @@ -297,8 +295,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
Expand Down
18 changes: 9 additions & 9 deletions internal/api/handlers/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ import (
"strings"
"time"

"github.com/autobrr/dashbrr/internal/cache"
"github.com/autobrr/dashbrr/internal/domain"

"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"golang.org/x/oauth2"

"github.com/autobrr/dashbrr/internal/services/cache"
"github.com/autobrr/dashbrr/internal/types"
)

type AuthHandler struct {
config *types.AuthConfig
config *domain.AuthConfig
cache cache.Store
oauth2Config *oauth2.Config
httpClient *http.Client
userinfoURL string
}

func NewAuthHandler(config *types.AuthConfig, store cache.Store) *AuthHandler {
func NewAuthHandler(config *domain.AuthConfig, store cache.Store) *AuthHandler {
httpClient := &http.Client{Timeout: 1 * time.Second}
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
Expand Down Expand Up @@ -276,7 +276,7 @@ func (h *AuthHandler) Callback(c *gin.Context) {
return
}

sessionData := types.SessionData{
sessionData := domain.SessionData{
AccessToken: token.AccessToken,
TokenType: token.TokenType,
RefreshToken: token.RefreshToken,
Expand Down Expand Up @@ -380,7 +380,7 @@ func (h *AuthHandler) VerifyToken(c *gin.Context) {
defer cancel()

sessionKey := fmt.Sprintf("oidc:session:%s", sessionID)
var sessionData types.SessionData
var sessionData domain.SessionData
if err := h.cache.Get(ctx, sessionKey, &sessionData); err != nil {
if ctx.Err() != nil {
log.Error().Err(ctx.Err()).Msg("Context canceled while verifying token")
Expand Down Expand Up @@ -410,7 +410,7 @@ func (h *AuthHandler) RefreshToken(c *gin.Context) {
}

sessionKey := fmt.Sprintf("oidc:session:%s", sessionID)
var sessionData types.SessionData
var sessionData domain.SessionData
if err := h.cache.Get(c.Request.Context(), sessionKey, &sessionData); err != nil {
if err == cache.ErrKeyNotFound {
log.Debug().Msg("session not found or expired")
Expand Down Expand Up @@ -470,7 +470,7 @@ func (h *AuthHandler) UserInfo(c *gin.Context) {
}

sessionKey := fmt.Sprintf("oidc:session:%s", sessionID)
var sessionData types.SessionData
var sessionData domain.SessionData
if err := h.cache.Get(c.Request.Context(), sessionKey, &sessionData); err != nil {
c.JSON(http.StatusUnauthorized, gin.H{"error": "Invalid session"})
return
Expand Down
10 changes: 5 additions & 5 deletions internal/api/handlers/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"

"github.com/autobrr/dashbrr/internal/types"
"github.com/autobrr/dashbrr/internal/domain"
)

// MockStore is a mock implementation of cache.Store
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestNewAuthHandler(t *testing.T) {
defer ts.Close()
serverURL = ts.URL

config := &types.AuthConfig{
config := &domain.AuthConfig{
Issuer: serverURL,
ClientID: "test-client-id",
ClientSecret: "test-client-secret",
Expand Down Expand Up @@ -121,7 +121,7 @@ func TestNewAuthHandler_DiscoveryFailed(t *testing.T) {
defer ts.Close()
serverURL = ts.URL

config := &types.AuthConfig{
config := &domain.AuthConfig{
Issuer: serverURL,
ClientID: "test-client-id",
ClientSecret: "test-client-secret",
Expand Down Expand Up @@ -164,7 +164,7 @@ func TestCallback_NoCode(t *testing.T) {
// No mock expectations needed for this test as no cache methods are called

handler := &AuthHandler{
config: &types.AuthConfig{
config: &domain.AuthConfig{
Issuer: "https://test.auth0.com",
ClientID: "test-client-id",
ClientSecret: "test-client-secret",
Expand All @@ -191,7 +191,7 @@ func TestLogout_NoFrontendURL(t *testing.T) {
// No mock expectations needed for this test as no cache methods are called

handler := &AuthHandler{
config: &types.AuthConfig{
config: &domain.AuthConfig{
Issuer: "https://test.auth0.com",
ClientID: "test-client-id",
ClientSecret: "test-client-secret",
Expand Down
Loading
Loading