Skip to content

Commit

Permalink
fix: make api-key less restrictive (#270)
Browse files Browse the repository at this point in the history
* fix: make api-key less restrictive

Signed-off-by: Devin Buhl <devin@buhl.casa>

* fix: update tests

Signed-off-by: Devin Buhl <devin@buhl.casa>

---------

Signed-off-by: Devin Buhl <devin@buhl.casa>
  • Loading branch information
onedr0p authored Feb 28, 2024
1 parent f9543a2 commit 0cb3186
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions internal/arr/config/arr.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/arr/config/arr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
Expand Down

0 comments on commit 0cb3186

Please sign in to comment.