|
1
|
|
|
package config |
|
2
|
|
|
|
|
3
|
|
|
import ( |
|
4
|
|
|
"time" |
|
5
|
|
|
|
|
6
|
|
|
"github.com/golang-jwt/jwt/v4" |
|
7
|
|
|
"github.com/memnix/memnix-rest/pkg/env" |
|
8
|
|
|
"github.com/memnix/memnix-rest/pkg/json" |
|
9
|
|
|
) |
|
10
|
|
|
|
|
11
|
|
|
var JSONHelper = json.NewJSON(&json.GoJson{}) |
|
12
|
|
|
|
|
13
|
|
|
var EnvHelper = env.NewMyEnv(&env.OsEnv{}) |
|
14
|
|
|
|
|
15
|
|
|
const ( |
|
16
|
|
|
ExpirationTimeInHours = 24 // Expiration time in hours |
|
17
|
|
|
SQLMaxOpenConns = 50 // Max number of open connections to the database |
|
18
|
|
|
SQLMaxIdleConns = 10 // Max number of connections in the idle connection pool |
|
19
|
|
|
|
|
20
|
|
|
BCryptCost = 11 // Cost to use for BCrypt |
|
21
|
|
|
|
|
22
|
|
|
CleaningInterval = 15 * time.Minute |
|
23
|
|
|
|
|
24
|
|
|
OauthStateLength = 16 // Length of the state for oauth |
|
25
|
|
|
OauthStateDuration = 10 * time.Minute // Duration of the state for oauth |
|
26
|
|
|
|
|
27
|
|
|
RedisMinIdleConns = 200 |
|
28
|
|
|
RedisPoolSize = 12000 |
|
29
|
|
|
RedisPoolTimeout = 240 * time.Second |
|
30
|
|
|
RedisDefaultExpireTime = 6 * time.Hour |
|
31
|
|
|
RedisOwnedExpireTime = 2 * time.Hour |
|
32
|
|
|
) |
|
33
|
|
|
|
|
34
|
|
|
var JwtSigningMethod = jwt.SigningMethodHS256 // JWTSigningMethod is the signing method for JWT |
|
35
|
|
|
|
|
36
|
|
|
// PasswordConfigStruct is the struct for the password config |
|
37
|
|
|
type PasswordConfigStruct struct { |
|
38
|
|
|
Iterations uint32 // Number of iterations to use for Argon2ID |
|
39
|
|
|
Memory uint32 // Memory to use for Argon2ID |
|
40
|
|
|
Threads uint8 // Number of threads to use for Argon2ID |
|
41
|
|
|
KeyLen uint32 // Key length to use for Argon2ID |
|
42
|
|
|
SaltLen uint32 // Salt length to use for Argon2ID |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
func IsProduction() bool { |
|
46
|
|
|
return EnvHelper.GetEnv("APP_ENV") != "dev" |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
func IsDevelopment() bool { |
|
50
|
|
|
return EnvHelper.GetEnv("APP_ENV") == "dev" |
|
51
|
|
|
} |
|
52
|
|
|
|