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 {
204204 return nil
205205 }
206206
207- encryptionString := os .Getenv ("SEMAPHORE_ACCESS_KEY_ENCRYPTION" )
208-
209- if encryptionString == "" {
210- encryptionString = util .Config .AccessKeyEncryption
211- }
207+ encryptionString := util .Config .GetAccessKeyEncryption ()
212208
213209 if encryptionString == "" {
214210 secret := base64 .StdEncoding .EncodeToString (plaintext )
@@ -289,11 +285,7 @@ func (key *AccessKey) DeserializeSecret() error {
289285 return err
290286 }
291287
292- encryptionString := os .Getenv ("SEMAPHORE_ACCESS_KEY_ENCRYPTION" )
293-
294- if encryptionString == "" {
295- encryptionString = util .Config .AccessKeyEncryption
296- }
288+ encryptionString := util .Config .GetAccessKeyEncryption ()
297289
298290 if encryptionString == "" {
299291 err = key .unmarshalAppropriateField (ciphertext )
Original file line number Diff line number Diff line change @@ -69,8 +69,11 @@ type ConfigType struct {
6969 TmpPath string `json:"tmp_path"`
7070
7171 // 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.
7477 AccessKeyEncryption string `json:"access_key_encryption"`
7578
7679 // email alerting
@@ -122,6 +125,16 @@ func (conf *ConfigType) ToJSON() ([]byte, error) {
122125 return json .MarshalIndent (& conf , " " , "\t " )
123126}
124127
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+
125138// ConfigInit reads in cli flags, and switches actions appropriately on them
126139func ConfigInit (configPath string ) {
127140 loadConfig (configPath )
You can’t perform that action at this time.
0 commit comments