-
Notifications
You must be signed in to change notification settings - Fork 9
/
server_settings_defaults.go
99 lines (92 loc) · 2.93 KB
/
server_settings_defaults.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package model
import "time"
// Default Server Settings settings
var DefaultServerSettings = ServerSettings{
General: GeneralServerSettings{
Host: "http://localhost:8081",
Port: "8081",
Issuer: "Identifo",
},
Storage: StorageSettings{
DefaultStorage: DatabaseSettings{Type: DBTypeMem},
AppStorage: DatabaseSettings{Type: DBTypeDefault},
UserStorage: DatabaseSettings{Type: DBTypeDefault},
TokenStorage: DatabaseSettings{Type: DBTypeDefault},
TokenBlacklist: DatabaseSettings{Type: DBTypeDefault},
VerificationCodeStorage: DatabaseSettings{Type: DBTypeDefault},
InviteStorage: DatabaseSettings{Type: DBTypeDefault},
ManagementKeysStorage: DatabaseSettings{Type: DBTypeDefault},
},
SessionStorage: SessionStorageSettings{
Type: SessionStorageMem,
SessionDuration: SessionDuration{Duration: time.Second * 300},
},
KeyStorage: FileStorageSettings{
Type: FileStorageTypeLocal,
Local: FileStorageLocal{
Path: "./jwt/test_artifacts/private.pem",
},
},
Login: LoginSettings{
LoginWith: LoginWith{
Phone: true,
Username: true,
Federated: false,
FederatedOIDC: false,
},
TFAType: TFATypeApp,
TFAResendTimeout: 30,
},
Services: ServicesSettings{
Email: EmailServiceSettings{
Type: EmailServiceMock,
},
SMS: SMSServiceSettings{
Type: SMSServiceMock,
},
},
AdminPanel: AdminPanelSettings{Enabled: true},
LoginWebApp: FileStorageSettings{Type: FileStorageTypeNone},
EmailTemplates: FileStorageSettings{Type: FileStorageTypeNone},
AdminAccount: AdminAccountSettings{
LoginEnvName: "IDENTIFO_ADMIN_LOGIN",
PasswordEnvName: "IDENTIFO_ADMIN_PASSWORD",
},
}
// Check server settings and apply changes if needed
func (ss *ServerSettings) RewriteDefaults() {
// if login web app empty - set default values
if len(ss.LoginWebApp.Type) == 0 {
ss.LoginWebApp = DefaultServerSettings.LoginWebApp
}
if len(ss.EmailTemplates.Type) == 0 {
ss.EmailTemplates = DefaultServerSettings.EmailTemplates
}
if len(ss.AdminAccount.LoginEnvName) == 0 {
ss.AdminAccount = DefaultServerSettings.AdminAccount
}
if len(ss.Storage.AppStorage.Type) == 0 {
ss.Storage.AppStorage.Type = DBTypeDefault
}
if len(ss.Storage.UserStorage.Type) == 0 {
ss.Storage.UserStorage.Type = DBTypeDefault
}
if len(ss.Storage.TokenBlacklist.Type) == 0 {
ss.Storage.TokenStorage.Type = DBTypeDefault
}
if len(ss.Storage.TokenBlacklist.Type) == 0 {
ss.Storage.TokenStorage.Type = DBTypeDefault
}
if len(ss.Storage.VerificationCodeStorage.Type) == 0 {
ss.Storage.VerificationCodeStorage.Type = DBTypeDefault
}
if len(ss.Storage.InviteStorage.Type) == 0 {
ss.Storage.InviteStorage.Type = DBTypeDefault
}
if len(ss.Storage.ManagementKeysStorage.Type) == 0 {
ss.Storage.ManagementKeysStorage.Type = DBTypeDefault
}
if len(ss.Storage.TokenBlacklist.Type) == 0 {
ss.Storage.TokenBlacklist.Type = DBTypeDefault
}
}