|
2 | 2 | package httpclient |
3 | 3 |
|
4 | 4 | import ( |
5 | | - "errors" |
6 | 5 | "fmt" |
7 | 6 | "net/http" |
8 | 7 | "os" |
9 | 8 | "path/filepath" |
10 | | - "regexp" |
11 | 9 | "strconv" |
12 | 10 | "strings" |
13 | 11 | "time" |
@@ -38,52 +36,6 @@ func validateFilePath(path string) (string, error) { |
38 | 36 |
|
39 | 37 | } |
40 | 38 |
|
41 | | -// validateClientID checks if a client ID is a valid UUID. |
42 | | -func validateValidClientID(clientID string) error { |
43 | | - uuidRegex := `^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$` |
44 | | - if regexp.MustCompile(uuidRegex).MatchString(clientID) { |
45 | | - return nil |
46 | | - } |
47 | | - return errors.New("clientID failed regex check") |
48 | | -} |
49 | | - |
50 | | -func validateClientSecret(clientSecret string) error { |
51 | | - if len(clientSecret) < 16 { |
52 | | - return errors.New("client secret must be at least 16 characters long") |
53 | | - } |
54 | | - |
55 | | - if matched, _ := regexp.MatchString(`[a-z]`, clientSecret); !matched { |
56 | | - return errors.New("client secret must contain at least one lowercase letter") |
57 | | - } |
58 | | - |
59 | | - if matched, _ := regexp.MatchString(`[A-Z]`, clientSecret); !matched { |
60 | | - return errors.New("client secret must contain at least one uppercase letter") |
61 | | - } |
62 | | - |
63 | | - if matched, _ := regexp.MatchString(`\d`, clientSecret); !matched { |
64 | | - return errors.New("client secret must contain at least one digit") |
65 | | - } |
66 | | - |
67 | | - return nil |
68 | | -} |
69 | | - |
70 | | -// validateUsername checks if a username meets the minimum requirements. |
71 | | -func validateUsername(username string) error { |
72 | | - usernameRegex := `^[a-zA-Z0-9!@#$%^&*()_\-\+=\[\]{\}\\|;:'",<.>/?]+$` |
73 | | - if !regexp.MustCompile(usernameRegex).MatchString(username) { |
74 | | - return errors.New("username failed regex test") |
75 | | - } |
76 | | - return nil |
77 | | -} |
78 | | - |
79 | | -// validatePassword checks if a password meets the minimum requirements. |
80 | | -func validatePassword(password string) error { |
81 | | - if len(password) < 8 { |
82 | | - return errors.New("password not long enough") |
83 | | - } |
84 | | - return nil |
85 | | -} |
86 | | - |
87 | 39 | // getEnvAsString reads an environment variable as a string, with a fallback default value. |
88 | 40 | func getEnvAsString(name string, defaultVal string) string { |
89 | 41 | if value, exists := os.LookupEnv(name); exists { |
|
0 commit comments