1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2024-11-28 18:11:17 +02:00

increased max allowed token duration

This commit is contained in:
Gani Georgiev 2022-08-25 10:57:50 +03:00
parent 49b084cf50
commit a908d20dcd
2 changed files with 11 additions and 3 deletions

View File

@ -223,7 +223,7 @@ type TokenConfig struct {
func (c TokenConfig) Validate() error {
return validation.ValidateStruct(&c,
validation.Field(&c.Secret, validation.Required, validation.Length(30, 300)),
validation.Field(&c.Duration, validation.Required, validation.Min(5), validation.Max(31536000)),
validation.Field(&c.Duration, validation.Required, validation.Min(5), validation.Max(63072000)),
)
}

View File

@ -224,15 +224,23 @@ func TestTokenConfigValidate(t *testing.T) {
// invalid data
{
core.TokenConfig{
Secret: "test",
Secret: strings.Repeat("a", 5),
Duration: 4,
},
true,
},
// valid secret but invalid duration
{
core.TokenConfig{
Secret: strings.Repeat("a", 30),
Duration: 63072000 + 1,
},
true,
},
// valid data
{
core.TokenConfig{
Secret: "testtesttesttesttesttesttestte",
Secret: strings.Repeat("a", 30),
Duration: 100,
},
false,