File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -204,11 +204,7 @@ func (key *AccessKey) SerializeSecret() error {
204
204
return nil
205
205
}
206
206
207
- encryptionString := os .Getenv ("SEMAPHORE_ACCESS_KEY_ENCRYPTION" )
208
-
209
- if encryptionString == "" {
210
- encryptionString = util .Config .AccessKeyEncryption
211
- }
207
+ encryptionString := util .Config .GetAccessKeyEncryption ()
212
208
213
209
if encryptionString == "" {
214
210
secret := base64 .StdEncoding .EncodeToString (plaintext )
@@ -289,11 +285,7 @@ func (key *AccessKey) DeserializeSecret() error {
289
285
return err
290
286
}
291
287
292
- encryptionString := os .Getenv ("SEMAPHORE_ACCESS_KEY_ENCRYPTION" )
293
-
294
- if encryptionString == "" {
295
- encryptionString = util .Config .AccessKeyEncryption
296
- }
288
+ encryptionString := util .Config .GetAccessKeyEncryption ()
297
289
298
290
if encryptionString == "" {
299
291
err = key .unmarshalAppropriateField (ciphertext )
Original file line number Diff line number Diff line change @@ -69,8 +69,11 @@ type ConfigType struct {
69
69
TmpPath string `json:"tmp_path"`
70
70
71
71
// cookie hashing & encryption
72
- CookieHash string `json:"cookie_hash"`
73
- CookieEncryption string `json:"cookie_encryption"`
72
+ CookieHash string `json:"cookie_hash"`
73
+ CookieEncryption string `json:"cookie_encryption"`
74
+ // AccessKeyEncryption is BASE64 encoded byte array used
75
+ // for encrypting and decrypting access keys stored in database.
76
+ // Do not use it! Use method GetAccessKeyEncryption instead of it.
74
77
AccessKeyEncryption string `json:"access_key_encryption"`
75
78
76
79
// email alerting
@@ -122,6 +125,16 @@ func (conf *ConfigType) ToJSON() ([]byte, error) {
122
125
return json .MarshalIndent (& conf , " " , "\t " )
123
126
}
124
127
128
+ func (conf * ConfigType ) GetAccessKeyEncryption () string {
129
+ ret := os .Getenv ("SEMAPHORE_ACCESS_KEY_ENCRYPTION" )
130
+
131
+ if ret == "" {
132
+ ret = conf .AccessKeyEncryption
133
+ }
134
+
135
+ return ret
136
+ }
137
+
125
138
// ConfigInit reads in cli flags, and switches actions appropriately on them
126
139
func ConfigInit (configPath string ) {
127
140
loadConfig (configPath )
You can’t perform that action at this time.
0 commit comments