@@ -7,19 +7,6 @@ import (
77 "encoding/json"
88 "errors"
99 "fmt"
10- "github.com/aws/aws-sdk-go/aws/awserr"
11- "github.com/aws/aws-sdk-go/service/s3"
12- "github.com/forceu/gokapi/internal/configuration"
13- "github.com/forceu/gokapi/internal/configuration/cloudconfig"
14- "github.com/forceu/gokapi/internal/configuration/configupgrade"
15- "github.com/forceu/gokapi/internal/configuration/database"
16- "github.com/forceu/gokapi/internal/configuration/database/dbabstraction"
17- "github.com/forceu/gokapi/internal/encryption"
18- "github.com/forceu/gokapi/internal/environment"
19- "github.com/forceu/gokapi/internal/helper"
20- "github.com/forceu/gokapi/internal/models"
21- "github.com/forceu/gokapi/internal/storage/filesystem/s3filesystem/aws"
22- "github.com/forceu/gokapi/internal/webserver/authentication"
2310 "html/template"
2411 "io"
2512 "io/fs"
@@ -33,6 +20,20 @@ import (
3320 "strings"
3421 "syscall"
3522 "time"
23+
24+ "github.com/aws/aws-sdk-go/aws/awserr"
25+ "github.com/aws/aws-sdk-go/service/s3"
26+ "github.com/forceu/gokapi/internal/configuration"
27+ "github.com/forceu/gokapi/internal/configuration/cloudconfig"
28+ "github.com/forceu/gokapi/internal/configuration/configupgrade"
29+ "github.com/forceu/gokapi/internal/configuration/database"
30+ "github.com/forceu/gokapi/internal/configuration/database/dbabstraction"
31+ "github.com/forceu/gokapi/internal/encryption"
32+ "github.com/forceu/gokapi/internal/environment"
33+ "github.com/forceu/gokapi/internal/helper"
34+ "github.com/forceu/gokapi/internal/models"
35+ "github.com/forceu/gokapi/internal/storage/filesystem/s3filesystem/aws"
36+ "github.com/forceu/gokapi/internal/webserver/authentication"
3637)
3738
3839// webserverDir is the embedded version of the "static" folder
@@ -244,6 +245,7 @@ func toConfiguration(formObjects *[]jsonFormObject) (models.Configuration, *clou
244245 MaxMemory : parsedEnv .MaxMemory ,
245246 DataDir : parsedEnv .DataDir ,
246247 MaxParallelUploads : parsedEnv .MaxParallelUploads ,
248+ MinLengthPassword : parsedEnv .MinLengthPassword ,
247249 ChunkSize : parsedEnv .ChunkSizeMB ,
248250 ConfigVersion : configupgrade .CurrentConfigVersion ,
249251 Authentication : models.AuthenticationConfig {},
@@ -644,8 +646,9 @@ func parseEncryptionAndDelete(result *models.Configuration, formObjects *[]jsonF
644646 if encLevel == encryption .LocalEncryptionInput || encLevel == encryption .FullEncryptionInput {
645647 result .Encryption .Salt = helper .GenerateRandomString (30 )
646648 result .Encryption .ChecksumSalt = helper .GenerateRandomString (30 )
647- if len (masterPw ) < configuration .MinLengthPassword {
648- return configuration.End2EndReconfigParameters {}, errors .New ("password is less than " + strconv .Itoa (configuration .MinLengthPassword ) + " characters long" )
649+ minLength := environment .New ().MinLengthPassword
650+ if len (masterPw ) < minLength {
651+ return configuration.End2EndReconfigParameters {}, errors .New ("password is less than " + strconv .Itoa (minLength ) + " characters long" )
649652 }
650653 result .Encryption .Checksum = encryption .PasswordChecksum (masterPw , result .Encryption .ChecksumSalt )
651654 }
@@ -705,6 +708,7 @@ type setupView struct {
705708 CloudSettings cloudconfig.CloudConfig
706709 DatabaseSettings models.DbConnection
707710 ProtectedUrls []string
711+ MinPasswordLength int
708712}
709713
710714func (v * setupView ) loadFromConfig () {
@@ -717,6 +721,7 @@ func (v *setupView) loadFromConfig() {
717721 v .HasAwsFeature = aws .IsIncludedInBuild
718722 v .ProtectedUrls = protectedUrls
719723 if isInitialSetup {
724+ v .MinPasswordLength = environment .New ().MinLengthPassword
720725 return
721726 }
722727 configuration .Load ()
0 commit comments