From 0cb318682ee0733e460aae27b6acdb0aa1045162 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Wed, 28 Feb 2024 15:45:53 -0500 Subject: [PATCH] fix: make api-key less restrictive (#270) * fix: make api-key less restrictive Signed-off-by: Devin Buhl * fix: update tests Signed-off-by: Devin Buhl --------- Signed-off-by: Devin Buhl --- internal/arr/config/arr.go | 8 ++++---- internal/arr/config/arr_test.go | 2 +- internal/config/config.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/arr/config/arr.go b/internal/arr/config/arr.go index 5fd2389..e27bb3b 100644 --- a/internal/arr/config/arr.go +++ b/internal/arr/config/arr.go @@ -39,9 +39,9 @@ type ArrConfig struct { FormAuth bool `koanf:"form-auth"` EnableUnknownQueueItems bool `koanf:"enable-unknown-queue-items"` EnableAdditionalMetrics bool `koanf:"enable-additional-metrics"` - URL string `koanf:"url" validate:"required|url"` // stores rendered Arr URL (with api version) - ApiKey string `koanf:"api-key" validate:"required|regex:(^[a-z0-9]{32}$)"` // stores the API key - DisableSSLVerify bool `koanf:"disable-ssl-verify"` // stores the disable SSL verify flag + URL string `koanf:"url" validate:"required|url"` // stores rendered Arr URL (with api version) + ApiKey string `koanf:"api-key" validate:"required|regex:(^[a-zA-Z0-9]{20,32}$)"` // stores the API key + DisableSSLVerify bool `koanf:"disable-ssl-verify"` // stores the disable SSL verify flag Prowlarr ProwlarrConfig `koanf:"prowlarr"` Bazarr BazarrConfig `koanf:"bazarr"` k *koanf.Koanf @@ -130,7 +130,7 @@ func (c *ArrConfig) Validate() error { func (c ArrConfig) Messages() map[string]string { return validate.MS{ - "ApiKey.regex": "api-key must be a 32 character hex string", + "ApiKey.regex": "api-key must be a 20-32 character alphanumeric string", "LogLevel.ValidateLogLevel": "log-level must be one of: debug, info, warn, error, dpanic, panic, fatal", } } diff --git a/internal/arr/config/arr_test.go b/internal/arr/config/arr_test.go index db96baa..462d4bb 100644 --- a/internal/arr/config/arr_test.go +++ b/internal/arr/config/arr_test.go @@ -213,7 +213,7 @@ func TestValidate(t *testing.T) { name: "bad-api-key", config: &ArrConfig{ URL: "http://localhost", - ApiKey: "abcdef0123456789abcdef01234567", + ApiKey: "abcdef0123456789abc", ApiVersion: "v3", }, valid: false, diff --git a/internal/config/config.go b/internal/config/config.go index cd193c7..a7a24c3 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -111,7 +111,7 @@ func (c *Config) Validate() error { func (c Config) Messages() map[string]string { return validate.MS{ - "ApiKey.regex": "api-key must be a 32 character hex string", + "ApiKey.regex": "api-key must be a 20-32 character alphanumeric string", "LogLevel.ValidateLogLevel": "log-level must be one of: debug, info, warn, error, dpanic, panic, fatal", } }